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