Examples.js 30 KB

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