Examples.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
  2. smalltalk.addMethod(
  3. '_increase',
  4. smalltalk.method({
  5. selector: 'increase',
  6. category: 'actions',
  7. fn: function (){
  8. var self=this;
  9. self['@count']=smalltalk.send(self['@count'], "__plus", [(1)]);
  10. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  11. return self;},
  12. source: unescape('increase%0A%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D'),
  13. messageSends: [unescape("+"), "contents:", "with:", "asString"],
  14. referencedClasses: []
  15. }),
  16. smalltalk.Counter);
  17. smalltalk.addMethod(
  18. '_decrease',
  19. smalltalk.method({
  20. selector: 'decrease',
  21. category: 'actions',
  22. fn: function (){
  23. var self=this;
  24. self['@count']=smalltalk.send(self['@count'], "__minus", [(1)]);
  25. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  26. return self;},
  27. source: unescape('decrease%0A%20%20%20%20count%20%3A%3D%20count%20-%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D'),
  28. messageSends: [unescape("-"), "contents:", "with:", "asString"],
  29. referencedClasses: []
  30. }),
  31. smalltalk.Counter);
  32. smalltalk.addMethod(
  33. '_initialize',
  34. smalltalk.method({
  35. selector: 'initialize',
  36. category: 'initialization',
  37. fn: function (){
  38. var self=this;
  39. smalltalk.send(self, "_initialize", [], smalltalk.Widget);
  40. self['@count']=(0);
  41. return self;},
  42. source: unescape('initialize%0A%20%20%20%20super%20initialize.%0A%20%20%20%20count%20%3A%3D%200'),
  43. messageSends: ["initialize"],
  44. referencedClasses: []
  45. }),
  46. smalltalk.Counter);
  47. smalltalk.addMethod(
  48. '_renderOn_',
  49. smalltalk.method({
  50. selector: 'renderOn:',
  51. category: 'rendering',
  52. fn: function (html){
  53. var self=this;
  54. self['@header']=(function($rec){smalltalk.send($rec, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(html, "_h1", []));
  55. (function($rec){smalltalk.send($rec, "_with_", [unescape("++")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_increase", []);})]);})(smalltalk.send(html, "_button", []));
  56. (function($rec){smalltalk.send($rec, "_with_", [unescape("--")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_decrease", []);})]);})(smalltalk.send(html, "_button", []));
  57. return self;},
  58. source: unescape('renderOn%3A%20html%0A%20%20%20%20header%20%3A%3D%20html%20h1%20%0A%09with%3A%20count%20asString%3B%0A%09yourself.%0A%20%20%20%20html%20button%0A%09with%3A%20%27++%27%3B%0A%09onClick%3A%20%5Bself%20increase%5D.%0A%20%20%20%20html%20button%0A%09with%3A%20%27--%27%3B%0A%09onClick%3A%20%5Bself%20decrease%5D'),
  59. messageSends: ["with:", "asString", "yourself", "h1", "onClick:", "increase", "button", "decrease"],
  60. referencedClasses: []
  61. }),
  62. smalltalk.Counter);
  63. smalltalk.setup(smalltalk.Counter);
  64. smalltalk.addClass('Tetris', smalltalk.Widget, ['renderingContext', 'timer', 'speed', 'score', 'rows', 'movingPiece'], 'Examples');
  65. smalltalk.addMethod(
  66. '_width',
  67. smalltalk.method({
  68. selector: 'width',
  69. category: 'accessing',
  70. fn: function (){
  71. var self=this;
  72. return smalltalk.send(smalltalk.send(self, "_class", []), "_width", []);
  73. return self;},
  74. source: unescape('width%0A%09%5Eself%20class%20width'),
  75. messageSends: ["width", "class"],
  76. referencedClasses: []
  77. }),
  78. smalltalk.Tetris);
  79. smalltalk.addMethod(
  80. '_height',
  81. smalltalk.method({
  82. selector: 'height',
  83. category: 'accessing',
  84. fn: function (){
  85. var self=this;
  86. return smalltalk.send(smalltalk.send(self, "_class", []), "_height", []);
  87. return self;},
  88. source: unescape('height%0A%09%5Eself%20class%20height'),
  89. messageSends: ["height", "class"],
  90. referencedClasses: []
  91. }),
  92. smalltalk.Tetris);
  93. smalltalk.addMethod(
  94. '_squares',
  95. smalltalk.method({
  96. selector: 'squares',
  97. category: 'accessing',
  98. fn: function (){
  99. var self=this;
  100. return smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []);
  101. return self;},
  102. source: unescape('squares%0A%09%5Eself%20class%20squares'),
  103. messageSends: ["squares", "class"],
  104. referencedClasses: []
  105. }),
  106. smalltalk.Tetris);
  107. smalltalk.addMethod(
  108. '_gluePiece_',
  109. smalltalk.method({
  110. selector: 'gluePiece:',
  111. category: 'accessing',
  112. fn: function (aPiece){
  113. var self=this;
  114. smalltalk.send(aPiece, "_glueOn_", [self]);
  115. return self;},
  116. source: unescape('gluePiece%3A%20aPiece%0A%09aPiece%20glueOn%3A%20self'),
  117. messageSends: ["glueOn:"],
  118. referencedClasses: []
  119. }),
  120. smalltalk.Tetris);
  121. smalltalk.addMethod(
  122. '_rows',
  123. smalltalk.method({
  124. selector: 'rows',
  125. category: 'accessing',
  126. fn: function (){
  127. var self=this;
  128. return self['@rows'];
  129. return self;},
  130. source: unescape('rows%0A%09%22An%20array%20of%20rows.%20Each%20row%20is%20a%20collection%20of%20points.%22%0A%09%5Erows'),
  131. messageSends: [],
  132. referencedClasses: []
  133. }),
  134. smalltalk.Tetris);
  135. smalltalk.addMethod(
  136. '_addRow_',
  137. smalltalk.method({
  138. selector: 'addRow:',
  139. category: 'accessing',
  140. fn: function (aCollection){
  141. var self=this;
  142. smalltalk.send(smalltalk.send(self, "_rows", []), "_add_", [aCollection]);
  143. return self;},
  144. source: unescape('addRow%3A%20aCollection%0A%09self%20rows%20add%3A%20aCollection'),
  145. messageSends: ["add:", "rows"],
  146. referencedClasses: []
  147. }),
  148. smalltalk.Tetris);
  149. smalltalk.addMethod(
  150. '_startNewGame',
  151. smalltalk.method({
  152. selector: 'startNewGame',
  153. category: 'actions',
  154. fn: function (){
  155. var self=this;
  156. smalltalk.send(self, "_newGame", []);
  157. smalltalk.send(self['@timer'], "_ifNotNil_", [(function(){return smalltalk.send(self['@timer'], "_clearInterval", []);})]);
  158. self['@timer']=smalltalk.send((function(){return smalltalk.send(self, "_nextStep", []);}), "_valueWithInterval_", [self['@speed']]);
  159. return self;},
  160. source: unescape('startNewGame%0A%09self%20newGame.%0A%09timer%20ifNotNil%3A%20%5Btimer%20clearInterval%5D.%0A%09timer%20%3A%3D%20%5Bself%20nextStep%5D%20valueWithInterval%3A%20speed'),
  161. messageSends: ["newGame", "ifNotNil:", "clearInterval", "valueWithInterval:", "nextStep"],
  162. referencedClasses: []
  163. }),
  164. smalltalk.Tetris);
  165. smalltalk.addMethod(
  166. '_nextStep',
  167. smalltalk.method({
  168. selector: 'nextStep',
  169. category: 'actions',
  170. fn: function (){
  171. var self=this;
  172. smalltalk.send(self['@movingPiece'], "_ifNil_", [(function(){return smalltalk.send(self, "_newPiece", []);})]);
  173. smalltalk.send(smalltalk.send(self['@movingPiece'], "_canMoveIn_", [self]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@movingPiece'], "_position_", [smalltalk.send(smalltalk.send(self['@movingPiece'], "_position", []), "__plus", [smalltalk.send((0), "__at", [(1)])])]);}), (function(){return smalltalk.send(self, "_newPiece", []);})]);
  174. smalltalk.send(self, "_redraw", []);
  175. return self;},
  176. source: unescape('nextStep%0A%09movingPiece%20ifNil%3A%20%5Bself%20newPiece%5D.%0A%09%28movingPiece%20canMoveIn%3A%20self%29%0A%09%09ifTrue%3A%20%5BmovingPiece%20position%3A%20movingPiece%20position%20+%20%280@1%29%5D%0A%09%09ifFalse%3A%20%5Bself%20newPiece%5D.%0A%09self%20redraw'),
  177. messageSends: ["ifNil:", "newPiece", "ifTrue:ifFalse:", "canMoveIn:", "position:", unescape("+"), "position", unescape("@"), "redraw"],
  178. referencedClasses: []
  179. }),
  180. smalltalk.Tetris);
  181. smalltalk.addMethod(
  182. '_redraw',
  183. smalltalk.method({
  184. selector: 'redraw',
  185. category: 'actions',
  186. fn: function (){
  187. var self=this;
  188. smalltalk.send(self['@renderingContext'], "_clearRectFrom_to_", [smalltalk.send((0), "__at", [smalltalk.send(self, "_width", [])]), smalltalk.send((0), "__at", [smalltalk.send(self, "_height", [])])]);
  189. (function($rec){smalltalk.send($rec, "_drawMap", []);return smalltalk.send($rec, "_drawPiece", []);})(self);
  190. return self;},
  191. source: unescape('redraw%0A%09renderingContext%20clearRectFrom%3A%200@%20self%20width%20to%3A%200@%20self%20height.%0A%09self%20%0A%09%09drawMap%3B%0A%09%09drawPiece'),
  192. messageSends: ["clearRectFrom:to:", unescape("@"), "width", "height", "drawMap", "drawPiece"],
  193. referencedClasses: []
  194. }),
  195. smalltalk.Tetris);
  196. smalltalk.addMethod(
  197. '_drawMap',
  198. smalltalk.method({
  199. selector: 'drawMap',
  200. category: 'actions',
  201. fn: function (){
  202. var self=this;
  203. (function($rec){smalltalk.send($rec, "_fillStyle_", [unescape("%23fafafa")]);return smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send((0), "__at", [(0)]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [smalltalk.send(self, "_height", [])])]);})(self['@renderingContext']);
  204. (function($rec){smalltalk.send($rec, "_lineWidth_", [(0.5)]);return smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);})(self['@renderingContext']);
  205. smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_x", []), (function(each){var x=nil;
  206. x=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send(x, "__at", [(0)]), smalltalk.send(x, "__at", [smalltalk.send(self, "_height", [])])]);})]);
  207. smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_y", []), (function(each){var y=nil;
  208. y=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send((0), "__at", [y]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [y])]);})]);
  209. return self;},
  210. source: unescape('drawMap%0A%09renderingContext%20%0A%09%09fillStyle%3A%20%27%23fafafa%27%3B%0A%09%09fillRectFrom%3A%200@0%20to%3A%20self%20width@self%20height.%0A%09renderingContext%20%0A%09%09lineWidth%3A%200.5%3B%0A%09%09strokeStyle%3A%20%27%23999%27.%0A%090%20to%3A%20self%20class%20squares%20x%20do%3A%20%5B%3Aeach%20%7C%20%7C%20x%20%7C%0A%09%09x%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%20x@0%20to%3A%20x@self%20height%5D.%0A%090%20to%3A%20self%20class%20squares%20y%20do%3A%20%5B%3Aeach%20%7C%20%7C%20y%20%7C%0A%09%09y%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%200@y%20to%3A%20self%20width@y%5D.'),
  211. messageSends: ["fillStyle:", "fillRectFrom:to:", unescape("@"), "width", "height", "lineWidth:", "strokeStyle:", "to:do:", "x", "squares", "class", unescape("*"), "squareSize", "drawLineFrom:to:", "y"],
  212. referencedClasses: []
  213. }),
  214. smalltalk.Tetris);
  215. smalltalk.addMethod(
  216. '_drawLineFrom_to_',
  217. smalltalk.method({
  218. selector: 'drawLineFrom:to:',
  219. category: 'actions',
  220. fn: function (aPoint, anotherPoint){
  221. var self=this;
  222. (function($rec){smalltalk.send($rec, "_beginPath", []);smalltalk.send($rec, "_moveTo_", [aPoint]);smalltalk.send($rec, "_lineTo_", [anotherPoint]);return smalltalk.send($rec, "_stroke", []);})(self['@renderingContext']);
  223. return self;},
  224. source: unescape('drawLineFrom%3A%20aPoint%20to%3A%20anotherPoint%0A%09renderingContext%20%0A%09%09beginPath%3B%0A%09%09moveTo%3A%20aPoint%3B%0A%09%09lineTo%3A%20anotherPoint%3B%0A%09%09stroke'),
  225. messageSends: ["beginPath", "moveTo:", "lineTo:", "stroke"],
  226. referencedClasses: []
  227. }),
  228. smalltalk.Tetris);
  229. smalltalk.addMethod(
  230. '_newGame',
  231. smalltalk.method({
  232. selector: 'newGame',
  233. category: 'actions',
  234. fn: function (){
  235. var self=this;
  236. self['@rows']=[];
  237. self['@movingPiece']=nil;
  238. self['@speed']=(200);
  239. self['@score']=(0);
  240. return self;},
  241. source: unescape('newGame%0A%09rows%20%3A%3D%20%23%28%29.%0A%09movingPiece%20%3A%3D%20nil.%0A%09speed%20%3A%3D%20200.%0A%09score%20%3A%3D%200'),
  242. messageSends: [],
  243. referencedClasses: []
  244. }),
  245. smalltalk.Tetris);
  246. smalltalk.addMethod(
  247. '_newPiece',
  248. smalltalk.method({
  249. selector: 'newPiece',
  250. category: 'actions',
  251. fn: function (){
  252. var self=this;
  253. self['@movingPiece']=smalltalk.send(smalltalk.TetrisPiece, "_atRandom", []);
  254. return self;},
  255. source: unescape('newPiece%0A%09movingPiece%20%3A%3D%20TetrisPiece%20atRandom'),
  256. messageSends: ["atRandom"],
  257. referencedClasses: [smalltalk.nil]
  258. }),
  259. smalltalk.Tetris);
  260. smalltalk.addMethod(
  261. '_drawRows',
  262. smalltalk.method({
  263. selector: 'drawRows',
  264. category: 'actions',
  265. fn: function (){
  266. var self=this;
  267. smalltalk.send(smalltalk.send(self, "_rows", []), "_do_", [(function(each){return nil;})]);
  268. smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
  269. return self;},
  270. source: unescape('drawRows%0A%09self%20rows%20do%3A%20%5B%3Aeach%20%7C%5D.%0A%09movingPiece%20ifNotNil%3A%20%5BmovingPiece%20drawOn%3A%20renderingContext%5D'),
  271. messageSends: ["do:", "rows", "ifNotNil:", "drawOn:"],
  272. referencedClasses: []
  273. }),
  274. smalltalk.Tetris);
  275. smalltalk.addMethod(
  276. '_drawPiece',
  277. smalltalk.method({
  278. selector: 'drawPiece',
  279. category: 'actions',
  280. fn: function (){
  281. var self=this;
  282. smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
  283. return self;},
  284. source: unescape('drawPiece%0A%09movingPiece%20ifNotNil%3A%20%5B%0A%09%09movingPiece%20drawOn%3A%20renderingContext%5D'),
  285. messageSends: ["ifNotNil:", "drawOn:"],
  286. referencedClasses: []
  287. }),
  288. smalltalk.Tetris);
  289. smalltalk.addMethod(
  290. '_initialize',
  291. smalltalk.method({
  292. selector: 'initialize',
  293. category: 'initialization',
  294. fn: function (){
  295. var self=this;
  296. smalltalk.send(self, "_initialize", [], smalltalk.Widget);
  297. smalltalk.send(self, "_newGame", []);
  298. return self;},
  299. source: unescape('initialize%0A%09super%20initialize.%0A%09self%20newGame'),
  300. messageSends: ["initialize", "newGame"],
  301. referencedClasses: []
  302. }),
  303. smalltalk.Tetris);
  304. smalltalk.addMethod(
  305. '_renderOn_',
  306. smalltalk.method({
  307. selector: 'renderOn:',
  308. category: 'rendering',
  309. fn: function (html){
  310. var self=this;
  311. (function($rec){smalltalk.send($rec, "_class_", ["tetris"]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(smalltalk.send(html, "_h3", []), "_with_", ["Tetris"]);smalltalk.send(self, "_renderCanvasOn_", [html]);return smalltalk.send(self, "_renderButtonsOn_", [html]);})]);})(smalltalk.send(html, "_div", []));
  312. return self;},
  313. source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09class%3A%20%27tetris%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20h3%20with%3A%20%27Tetris%27.%0A%09%09%09self%20renderCanvasOn%3A%20html.%0A%09%09%09self%20renderButtonsOn%3A%20html%5D'),
  314. messageSends: ["class:", "with:", "h3", "renderCanvasOn:", "renderButtonsOn:", "div"],
  315. referencedClasses: []
  316. }),
  317. smalltalk.Tetris);
  318. smalltalk.addMethod(
  319. '_renderCanvasOn_',
  320. smalltalk.method({
  321. selector: 'renderCanvasOn:',
  322. category: 'rendering',
  323. fn: function (html){
  324. var self=this;
  325. var canvas=nil;
  326. canvas=smalltalk.send(html, "_canvas", []);
  327. smalltalk.send(canvas, "_at_put_", ["width", smalltalk.send(smalltalk.send(self, "_width", []), "_asString", [])]);
  328. smalltalk.send(canvas, "_at_put_", ["height", smalltalk.send(smalltalk.send(self, "_height", []), "_asString", [])]);
  329. self['@renderingContext']=smalltalk.send(smalltalk.CanvasRenderingContext, "_tagBrush_", [canvas]);
  330. smalltalk.send(self, "_redraw", []);
  331. return self;},
  332. source: unescape('renderCanvasOn%3A%20html%0A%09%7C%20canvas%20%7C%0A%09canvas%20%3A%3D%20html%20canvas.%0A%09canvas%20at%3A%20%27width%27%20put%3A%20self%20width%20asString.%0A%09canvas%20at%3A%20%27height%27%20put%3A%20self%20height%20asString.%0A%09renderingContext%20%3A%3D%20CanvasRenderingContext%20tagBrush%3A%20canvas.%0A%09self%20redraw'),
  333. messageSends: ["canvas", "at:put:", "asString", "width", "height", "tagBrush:", "redraw"],
  334. referencedClasses: [smalltalk.CanvasRenderingContext]
  335. }),
  336. smalltalk.Tetris);
  337. smalltalk.addMethod(
  338. '_renderButtonsOn_',
  339. smalltalk.method({
  340. selector: 'renderButtonsOn:',
  341. category: 'rendering',
  342. fn: function (html){
  343. var self=this;
  344. (function($rec){smalltalk.send($rec, "_class_", ["tetris_buttons"]);return smalltalk.send($rec, "_with_", [(function(){(function($rec){smalltalk.send($rec, "_with_", ["New game"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_startNewGame", []);})]);})(smalltalk.send(html, "_button", []));return (function($rec){smalltalk.send($rec, "_with_", [unescape("play/pause")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_update", []);})]);})(smalltalk.send(html, "_button", []));})]);})(smalltalk.send(html, "_div", []));
  345. return self;},
  346. source: unescape('renderButtonsOn%3A%20html%0A%09html%20div%20%0A%09%09class%3A%20%27tetris_buttons%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27New%20game%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20startNewGame%5D.%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27play/pause%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20update%5D%5D'),
  347. messageSends: ["class:", "with:", "onClick:", "startNewGame", "button", "update", "div"],
  348. referencedClasses: []
  349. }),
  350. smalltalk.Tetris);
  351. smalltalk.addMethod(
  352. '_squareSize',
  353. smalltalk.method({
  354. selector: 'squareSize',
  355. category: 'accessing',
  356. fn: function (){
  357. var self=this;
  358. return (22);
  359. return self;},
  360. source: unescape('squareSize%0A%09%5E22'),
  361. messageSends: [],
  362. referencedClasses: []
  363. }),
  364. smalltalk.Tetris.klass);
  365. smalltalk.addMethod(
  366. '_width',
  367. smalltalk.method({
  368. selector: 'width',
  369. category: 'accessing',
  370. fn: function (){
  371. var self=this;
  372. return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_x", [])]);
  373. return self;},
  374. source: unescape('width%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20x%29'),
  375. messageSends: [unescape("*"), "squareSize", "x", "squares"],
  376. referencedClasses: []
  377. }),
  378. smalltalk.Tetris.klass);
  379. smalltalk.addMethod(
  380. '_height',
  381. smalltalk.method({
  382. selector: 'height',
  383. category: 'accessing',
  384. fn: function (){
  385. var self=this;
  386. return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_y", [])]);
  387. return self;},
  388. source: unescape('height%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20y%29'),
  389. messageSends: [unescape("*"), "squareSize", "y", "squares"],
  390. referencedClasses: []
  391. }),
  392. smalltalk.Tetris.klass);
  393. smalltalk.addMethod(
  394. '_squares',
  395. smalltalk.method({
  396. selector: 'squares',
  397. category: 'accessing',
  398. fn: function (){
  399. var self=this;
  400. return smalltalk.send((10), "__at", [(15)]);
  401. return self;},
  402. source: unescape('squares%0A%09%5E10@15'),
  403. messageSends: [unescape("@")],
  404. referencedClasses: []
  405. }),
  406. smalltalk.Tetris.klass);
  407. smalltalk.setup(smalltalk.Tetris);
  408. smalltalk.addClass('TetrisPiece', smalltalk.Widget, ['rotation', 'position'], 'Examples');
  409. smalltalk.addMethod(
  410. '_rotation',
  411. smalltalk.method({
  412. selector: 'rotation',
  413. category: 'accessing',
  414. fn: function (){
  415. var self=this;
  416. return smalltalk.send(self['@rotation'], "_ifNil_", [(function(){return self['@rotation']=(1);})]);
  417. return self;},
  418. source: unescape('rotation%0A%09%5Erotation%20ifNil%3A%20%5Brotation%20%3A%3D%201%5D'),
  419. messageSends: ["ifNil:"],
  420. referencedClasses: []
  421. }),
  422. smalltalk.TetrisPiece);
  423. smalltalk.addMethod(
  424. '_rotation_',
  425. smalltalk.method({
  426. selector: 'rotation:',
  427. category: 'accessing',
  428. fn: function (aNumber){
  429. var self=this;
  430. self['@rotation']=aNumber;
  431. return self;},
  432. source: unescape('rotation%3A%20aNumber%0A%09rotation%20%3A%3D%20aNumber'),
  433. messageSends: [],
  434. referencedClasses: []
  435. }),
  436. smalltalk.TetrisPiece);
  437. smalltalk.addMethod(
  438. '_position',
  439. smalltalk.method({
  440. selector: 'position',
  441. category: 'accessing',
  442. fn: function (){
  443. var self=this;
  444. return smalltalk.send(self['@position'], "_ifNil_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_x", []), "__slash", [(2)]), "__minus", [(1)]), "__at", [(0)]);})]);
  445. return self;},
  446. source: unescape('position%0A%09%5Eposition%20ifNil%3A%20%5B%28Tetris%20squares%20x%20/%202%29%20-1%20@%200%5D'),
  447. messageSends: ["ifNil:", unescape("@"), unescape("-"), unescape("/"), "x", "squares"],
  448. referencedClasses: [smalltalk.Tetris]
  449. }),
  450. smalltalk.TetrisPiece);
  451. smalltalk.addMethod(
  452. '_position_',
  453. smalltalk.method({
  454. selector: 'position:',
  455. category: 'accessing',
  456. fn: function (aPoint){
  457. var self=this;
  458. return self['@position']=aPoint;
  459. return self;},
  460. source: unescape('position%3A%20aPoint%0A%09%5Eposition%20%3A%3D%20aPoint'),
  461. messageSends: [],
  462. referencedClasses: []
  463. }),
  464. smalltalk.TetrisPiece);
  465. smalltalk.addMethod(
  466. '_bounds',
  467. smalltalk.method({
  468. selector: 'bounds',
  469. category: 'accessing',
  470. fn: function (){
  471. var self=this;
  472. smalltalk.send(self, "_subclassResponsibility", []);
  473. return self;},
  474. source: unescape('bounds%0A%09self%20subclassResponsibility'),
  475. messageSends: ["subclassResponsibility"],
  476. referencedClasses: []
  477. }),
  478. smalltalk.TetrisPiece);
  479. smalltalk.addMethod(
  480. '_color',
  481. smalltalk.method({
  482. selector: 'color',
  483. category: 'accessing',
  484. fn: function (){
  485. var self=this;
  486. return unescape("%23afa");
  487. return self;},
  488. source: unescape('color%0A%09%5E%27%23afa%27'),
  489. messageSends: [],
  490. referencedClasses: []
  491. }),
  492. smalltalk.TetrisPiece);
  493. smalltalk.addMethod(
  494. '_height',
  495. smalltalk.method({
  496. selector: 'height',
  497. category: 'accessing',
  498. fn: function (){
  499. var self=this;
  500. return (2);
  501. return self;},
  502. source: unescape('height%0A%09%5E2'),
  503. messageSends: [],
  504. referencedClasses: []
  505. }),
  506. smalltalk.TetrisPiece);
  507. smalltalk.addMethod(
  508. '_drawOn_',
  509. smalltalk.method({
  510. selector: 'drawOn:',
  511. category: 'drawing',
  512. fn: function (aRenderingContext){
  513. var self=this;
  514. smalltalk.send(aRenderingContext, "_fillStyle_", [smalltalk.send(self, "_color", [])]);
  515. smalltalk.send(smalltalk.send(self, "_bounds", []), "_do_", [(function(each){return (function($rec){smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);smalltalk.send($rec, "_lineWidth_", [(2)]);return smalltalk.send($rec, "_strokeRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);})(aRenderingContext);})]);
  516. return self;},
  517. source: unescape('drawOn%3A%20aRenderingContext%0A%09aRenderingContext%20fillStyle%3A%20self%20color.%0A%09self%20bounds%20do%3A%20%5B%3Aeach%20%7C%0A%09%09aRenderingContext%20%0A%09%09%09fillRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%3B%0A%09%09%09strokeStyle%3A%20%27%23999%27%3B%0A%09%09%09lineWidth%3A%202%3B%0A%09%09%09strokeRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%5D'),
  518. messageSends: ["fillStyle:", "color", "do:", "bounds", "fillRectFrom:to:", unescape("*"), unescape("+"), "position", "squareSize", unescape("@"), "strokeStyle:", "lineWidth:", "strokeRectFrom:to:"],
  519. referencedClasses: [smalltalk.Tetris]
  520. }),
  521. smalltalk.TetrisPiece);
  522. smalltalk.addMethod(
  523. '_canMove',
  524. smalltalk.method({
  525. selector: 'canMove',
  526. category: 'testing',
  527. fn: function (){
  528. var self=this;
  529. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
  530. return self;},
  531. source: unescape('canMove%0A%09%5Eself%20position%20y%20%3C%20%28Tetris%20squares%20y%20-%20self%20height%29'),
  532. messageSends: [unescape("%3C"), "y", "position", unescape("-"), "squares", "height"],
  533. referencedClasses: [smalltalk.Tetris]
  534. }),
  535. smalltalk.TetrisPiece);
  536. smalltalk.addMethod(
  537. '_canMoveIn_',
  538. smalltalk.method({
  539. selector: 'canMoveIn:',
  540. category: 'testing',
  541. fn: function (aTetris){
  542. var self=this;
  543. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(aTetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
  544. return self;},
  545. source: unescape('canMoveIn%3A%20aTetris%0A%09%5Eself%20position%20y%20%3C%20%28aTetris%20squares%20y%20-%20self%20height%29'),
  546. messageSends: [unescape("%3C"), "y", "position", unescape("-"), "squares", "height"],
  547. referencedClasses: []
  548. }),
  549. smalltalk.TetrisPiece);
  550. smalltalk.addMethod(
  551. '_atRandom',
  552. smalltalk.method({
  553. selector: 'atRandom',
  554. category: 'instance creation',
  555. fn: function (){
  556. var self=this;
  557. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_at_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_size", []), "_atRandom", [])]), "_new", []);
  558. return self;},
  559. source: unescape('atRandom%0A%09%5E%28self%20subclasses%20at%3A%20self%20subclasses%20size%20atRandom%29%20new'),
  560. messageSends: ["new", "at:", "subclasses", "atRandom", "size"],
  561. referencedClasses: []
  562. }),
  563. smalltalk.TetrisPiece.klass);
  564. smalltalk.setup(smalltalk.TetrisPiece);
  565. smalltalk.addClass('TetrisPieceO', smalltalk.TetrisPiece, [], 'Examples');
  566. smalltalk.addMethod(
  567. '_bounds',
  568. smalltalk.method({
  569. selector: 'bounds',
  570. category: 'accessing',
  571. fn: function (){
  572. var self=this;
  573. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  574. return self;},
  575. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself'),
  576. messageSends: ["add:", unescape("@"), "yourself", "new"],
  577. referencedClasses: [smalltalk.Array]
  578. }),
  579. smalltalk.TetrisPieceO);
  580. smalltalk.setup(smalltalk.TetrisPieceO);
  581. smalltalk.addClass('TetrisPieceL', smalltalk.TetrisPiece, [], 'Examples');
  582. smalltalk.addMethod(
  583. '_bounds',
  584. smalltalk.method({
  585. selector: 'bounds',
  586. category: 'accessing',
  587. fn: function (){
  588. var self=this;
  589. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  590. return self;},
  591. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%201@2%3B%0A%09%09yourself'),
  592. messageSends: ["add:", unescape("@"), "yourself", "new"],
  593. referencedClasses: [smalltalk.Array]
  594. }),
  595. smalltalk.TetrisPieceL);
  596. smalltalk.addMethod(
  597. '_color',
  598. smalltalk.method({
  599. selector: 'color',
  600. category: 'accessing',
  601. fn: function (){
  602. var self=this;
  603. return unescape("%23ffa");
  604. return self;},
  605. source: unescape('color%0A%09%5E%27%23ffa%27'),
  606. messageSends: [],
  607. referencedClasses: []
  608. }),
  609. smalltalk.TetrisPieceL);
  610. smalltalk.addMethod(
  611. '_height',
  612. smalltalk.method({
  613. selector: 'height',
  614. category: 'accessing',
  615. fn: function (){
  616. var self=this;
  617. return (3);
  618. return self;},
  619. source: unescape('height%0A%09%5E3'),
  620. messageSends: [],
  621. referencedClasses: []
  622. }),
  623. smalltalk.TetrisPieceL);
  624. smalltalk.setup(smalltalk.TetrisPieceL);
  625. smalltalk.addClass('TetrisPieceJ', smalltalk.TetrisPiece, [], 'Examples');
  626. smalltalk.addMethod(
  627. '_color',
  628. smalltalk.method({
  629. selector: 'color',
  630. category: 'accessing',
  631. fn: function (){
  632. var self=this;
  633. return unescape("%23aaf");
  634. return self;},
  635. source: unescape('color%0A%09%5E%27%23aaf%27'),
  636. messageSends: [],
  637. referencedClasses: []
  638. }),
  639. smalltalk.TetrisPieceJ);
  640. smalltalk.addMethod(
  641. '_bounds',
  642. smalltalk.method({
  643. selector: 'bounds',
  644. category: 'accessing',
  645. fn: function (){
  646. var self=this;
  647. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  648. return self;},
  649. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09add%3A%201@2%3B%0A%09%09add%3A%200@2%3B%0A%09%09yourself'),
  650. messageSends: ["add:", unescape("@"), "yourself", "new"],
  651. referencedClasses: [smalltalk.Array]
  652. }),
  653. smalltalk.TetrisPieceJ);
  654. smalltalk.addMethod(
  655. '_height',
  656. smalltalk.method({
  657. selector: 'height',
  658. category: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. return (3);
  662. return self;},
  663. source: unescape('height%0A%09%5E3'),
  664. messageSends: [],
  665. referencedClasses: []
  666. }),
  667. smalltalk.TetrisPieceJ);
  668. smalltalk.setup(smalltalk.TetrisPieceJ);
  669. smalltalk.addClass('TetrisPieceI', smalltalk.TetrisPiece, [], 'Examples');
  670. smalltalk.addMethod(
  671. '_color',
  672. smalltalk.method({
  673. selector: 'color',
  674. category: 'accessing',
  675. fn: function (){
  676. var self=this;
  677. return unescape("%23faa");
  678. return self;},
  679. source: unescape('color%0A%09%5E%27%23faa%27'),
  680. messageSends: [],
  681. referencedClasses: []
  682. }),
  683. smalltalk.TetrisPieceI);
  684. smalltalk.addMethod(
  685. '_bounds',
  686. smalltalk.method({
  687. selector: 'bounds',
  688. category: 'accessing',
  689. fn: function (){
  690. var self=this;
  691. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(3)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  692. return self;},
  693. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%200@3%3B%0A%09%09yourself'),
  694. messageSends: ["add:", unescape("@"), "yourself", "new"],
  695. referencedClasses: [smalltalk.Array]
  696. }),
  697. smalltalk.TetrisPieceI);
  698. smalltalk.addMethod(
  699. '_height',
  700. smalltalk.method({
  701. selector: 'height',
  702. category: 'accessing',
  703. fn: function (){
  704. var self=this;
  705. return (4);
  706. return self;},
  707. source: unescape('height%0A%09%5E4'),
  708. messageSends: [],
  709. referencedClasses: []
  710. }),
  711. smalltalk.TetrisPieceI);
  712. smalltalk.setup(smalltalk.TetrisPieceI);
  713. smalltalk.addClass('TetrisPieceT', smalltalk.TetrisPiece, [], 'Examples');
  714. smalltalk.addMethod(
  715. '_bounds',
  716. smalltalk.method({
  717. selector: 'bounds',
  718. category: 'accessing',
  719. fn: function (){
  720. var self=this;
  721. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((2), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  722. return self;},
  723. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%202@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself'),
  724. messageSends: ["add:", unescape("@"), "yourself", "new"],
  725. referencedClasses: [smalltalk.Array]
  726. }),
  727. smalltalk.TetrisPieceT);
  728. smalltalk.addMethod(
  729. '_color',
  730. smalltalk.method({
  731. selector: 'color',
  732. category: 'accessing',
  733. fn: function (){
  734. var self=this;
  735. return unescape("%23aaf");
  736. return self;},
  737. source: unescape('color%0A%09%5E%27%23aaf%27'),
  738. messageSends: [],
  739. referencedClasses: []
  740. }),
  741. smalltalk.TetrisPieceT);
  742. smalltalk.setup(smalltalk.TetrisPieceT);