entityjs 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/bin/entityjs +14 -0
- data/build/build_debug.bat +1 -0
- data/build/build_min.bat +1 -0
- data/build/config.php +64 -0
- data/build/debug.php +48 -0
- data/build/files.php +74 -0
- data/build/jsmin.php +376 -0
- data/build/min.php +50 -0
- data/changelog.txt +53 -0
- data/entityjs.gemspec +25 -0
- data/examples/keys/arrow.png +0 -0
- data/examples/keys/keys.html +59 -0
- data/examples/keys/keys.js +148 -0
- data/examples/mouse/mouse.html +58 -0
- data/examples/mouse/mouse.js +60 -0
- data/examples/scenes/home.png +0 -0
- data/examples/scenes/scenes.html +55 -0
- data/examples/scenes/scenes.js +134 -0
- data/examples/scenes/win.png +0 -0
- data/examples/sounds/sound1.mp3 +0 -0
- data/examples/sounds/sound1.ogg +0 -0
- data/examples/sounds/sounds.html +56 -0
- data/examples/sounds/sounds.js +44 -0
- data/examples/style/background.png +0 -0
- data/examples/style/sheet.css +762 -0
- data/examples/tiles/tiles.html +56 -0
- data/examples/tiles/tiles.js +85 -0
- data/examples/tiles/tiles.png +0 -0
- data/lib/blank/config.js +4 -0
- data/lib/blank/config.yml +21 -0
- data/lib/blank/home.js +11 -0
- data/lib/blank/init.js +7 -0
- data/lib/blank/load.js +21 -0
- data/lib/blank/play.html +29 -0
- data/lib/entity.debug.js +52 -0
- data/lib/entity.min.js +184 -0
- data/lib/entityjs/command.rb +37 -0
- data/lib/entityjs/comp.rb +11 -0
- data/lib/entityjs/game.rb +93 -0
- data/lib/entityjs/min.rb +11 -0
- data/lib/entityjs/refresh.rb +14 -0
- data/lib/entityjs/version.rb +3 -0
- data/lib/entityjs.rb +6 -0
- data/license.txt +1 -0
- data/spec/lib/entityjs/game_spec.rb +11 -0
- data/spec/spec_helper.rb +3 -0
- data/src/entityjs/core/component.js +306 -0
- data/src/entityjs/core/entity.js +516 -0
- data/src/entityjs/core/load.js +224 -0
- data/src/entityjs/core/query.js +410 -0
- data/src/entityjs/core/re.js +70 -0
- data/src/entityjs/core/system.js +125 -0
- data/src/entityjs/cycle/draw.js +185 -0
- data/src/entityjs/cycle/ticker.js +27 -0
- data/src/entityjs/cycle/tween.js +61 -0
- data/src/entityjs/cycle/update.js +86 -0
- data/src/entityjs/cycle/wait.js +22 -0
- data/src/entityjs/cycle/worker.js +9 -0
- data/src/entityjs/display/anchor.js +53 -0
- data/src/entityjs/display/bitfont.js +93 -0
- data/src/entityjs/display/bitmap.js +37 -0
- data/src/entityjs/display/circle.js +30 -0
- data/src/entityjs/display/font.js +41 -0
- data/src/entityjs/display/group.js +63 -0
- data/src/entityjs/display/rect.js +19 -0
- data/src/entityjs/display/screen.js +46 -0
- data/src/entityjs/display/sprite.js +37 -0
- data/src/entityjs/input/keyboard.js +150 -0
- data/src/entityjs/input/mouse.js +123 -0
- data/src/entityjs/input/pressed.js +81 -0
- data/src/entityjs/input/touch.js +28 -0
- data/src/entityjs/math/bind.js +76 -0
- data/src/entityjs/math/bisect.js +69 -0
- data/src/entityjs/math/body.js +39 -0
- data/src/entityjs/math/drag.js +39 -0
- data/src/entityjs/math/hitmap.js +165 -0
- data/src/entityjs/math/hittest.js +26 -0
- data/src/entityjs/math/physics.js +142 -0
- data/src/entityjs/math/point.js +57 -0
- data/src/entityjs/math/tile.js +91 -0
- data/src/entityjs/media/channel.js +93 -0
- data/src/entityjs/media/playlist.js +5 -0
- data/src/entityjs/media/sound.js +110 -0
- data/src/entityjs/net/socket.js +52 -0
- data/src/entityjs/pattern/arraymap.js +89 -0
- data/src/entityjs/pattern/flicker.js +214 -0
- data/src/entityjs/pattern/timestep.js +34 -0
- data/src/entityjs/save/database.js +7 -0
- data/src/entityjs/save/storage.js +57 -0
- data/src/entityjs/util/log.js +25 -0
- data/src/entityjs/util/polyfill.js +25 -0
- data/src/entityjs/util/random.js +38 -0
- data/src/entityjs/util/scene.js +101 -0
- data/src/entityjs/util/sheet.js +51 -0
- data/src/entityjs/util/support.js +132 -0
- metadata +156 -0
@@ -0,0 +1,410 @@
|
|
1
|
+
(function(re){
|
2
|
+
|
3
|
+
/*
|
4
|
+
Searches through all entities using the selector conditions
|
5
|
+
|
6
|
+
//identifiers
|
7
|
+
* identifies all
|
8
|
+
^ identifies a signal
|
9
|
+
# identifies an id
|
10
|
+
- identifies not
|
11
|
+
|
12
|
+
//select all entities
|
13
|
+
re('*');
|
14
|
+
|
15
|
+
//select all entities with 2d and ai components
|
16
|
+
re('2d ai');
|
17
|
+
|
18
|
+
//select all 2d entities without the monster component
|
19
|
+
re('2d -monster');
|
20
|
+
|
21
|
+
//select all draw entities and entities with the id equal to asset
|
22
|
+
re('draw #asset')
|
23
|
+
//returns a random entity
|
24
|
+
.random();
|
25
|
+
|
26
|
+
//select all entities with id of bob and player
|
27
|
+
//warning you cannot query for two ids
|
28
|
+
re('#bob player')
|
29
|
+
//takes values from all objects and returns an array
|
30
|
+
.pluck('width height');
|
31
|
+
|
32
|
+
//find all bitmap entities with update signal.
|
33
|
+
re('bitmap ^update');
|
34
|
+
|
35
|
+
//add color comp to all text components
|
36
|
+
re('text').comp('color');
|
37
|
+
|
38
|
+
//custom entity search
|
39
|
+
re(function(index){
|
40
|
+
|
41
|
+
if(entity.has('health') && entity.health > 0){
|
42
|
+
//add to query
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
|
46
|
+
//skip entity
|
47
|
+
return false;
|
48
|
+
})
|
49
|
+
//calls reset method on all entities
|
50
|
+
.method('reset');
|
51
|
+
|
52
|
+
//returns direct reference to first entity with id of player
|
53
|
+
re('#player').health = 100;
|
54
|
+
|
55
|
+
*/
|
56
|
+
var q = function(selector){
|
57
|
+
this._e = [];
|
58
|
+
|
59
|
+
if(selector){
|
60
|
+
this.query(selector);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
/*
|
65
|
+
Sort a query string into objects
|
66
|
+
*/
|
67
|
+
q._toObj = function(query){
|
68
|
+
if(q.c[query]){
|
69
|
+
return q.c[query];
|
70
|
+
}
|
71
|
+
|
72
|
+
//convert to object
|
73
|
+
var temp = query.split(' ');
|
74
|
+
var comps = [];
|
75
|
+
var signals = [];
|
76
|
+
var minus = [];
|
77
|
+
var id = '';
|
78
|
+
|
79
|
+
//split string
|
80
|
+
var fl;
|
81
|
+
var val;
|
82
|
+
for(var j = 0; j<temp.length; j++){
|
83
|
+
fl = temp[j].charAt(0);
|
84
|
+
val = temp[j].substr(1);
|
85
|
+
|
86
|
+
if(fl == '^'){
|
87
|
+
signals.push(val);
|
88
|
+
} else if(fl == '-'){
|
89
|
+
minus.push(val);
|
90
|
+
} else if(fl == '#'){
|
91
|
+
id = val;
|
92
|
+
} else {
|
93
|
+
comps.push(temp[j]);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
var comp = {
|
98
|
+
comp:comps,
|
99
|
+
signal:signals,
|
100
|
+
not:minus,
|
101
|
+
id:id
|
102
|
+
};
|
103
|
+
|
104
|
+
q.c[query] = comp;
|
105
|
+
|
106
|
+
return comp;
|
107
|
+
}
|
108
|
+
|
109
|
+
q.c = {};
|
110
|
+
|
111
|
+
var p = q.prototype;
|
112
|
+
|
113
|
+
p.query = function(select){
|
114
|
+
select = select || '';
|
115
|
+
var i = 0;
|
116
|
+
|
117
|
+
if(typeof select == 'string'){
|
118
|
+
|
119
|
+
if(select == '*'){
|
120
|
+
|
121
|
+
this._e = re._e.slice();
|
122
|
+
|
123
|
+
return this;
|
124
|
+
}
|
125
|
+
|
126
|
+
//optimize search and cache
|
127
|
+
var obj = q._toObj(select);
|
128
|
+
|
129
|
+
var en;
|
130
|
+
main : for(; i<re._e.length; i++){
|
131
|
+
en = re._e[i];
|
132
|
+
|
133
|
+
if(en.has(obj)){
|
134
|
+
|
135
|
+
this._e.push(en);
|
136
|
+
}
|
137
|
+
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
} else if(typeof select == 'function'){
|
142
|
+
|
143
|
+
for(; i<re._e.length; i++){
|
144
|
+
|
145
|
+
if(select.call(re._e[i], i, re._e.length)){
|
146
|
+
this._e.push(re._e[i]);
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
return this;
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
Returns an array with all queried entities.
|
158
|
+
*/
|
159
|
+
p.toArray = function(){
|
160
|
+
return this._e.slice();
|
161
|
+
}
|
162
|
+
|
163
|
+
/*
|
164
|
+
Calls the given method name on all entities.
|
165
|
+
|
166
|
+
re('enemies').method('rest');
|
167
|
+
*/
|
168
|
+
p.method = function(m){
|
169
|
+
var b = Array.prototype.slice.call(arguments, 1);
|
170
|
+
this.each(function(){
|
171
|
+
|
172
|
+
this[m].apply(this, b);
|
173
|
+
});
|
174
|
+
|
175
|
+
return this;
|
176
|
+
}
|
177
|
+
|
178
|
+
/*
|
179
|
+
example
|
180
|
+
re('draw').each(function(index, length){
|
181
|
+
|
182
|
+
});
|
183
|
+
|
184
|
+
returning false will break the loop
|
185
|
+
*/
|
186
|
+
p.each = function(m){
|
187
|
+
var l = this._e.length, i = -1, e;
|
188
|
+
|
189
|
+
while(++i < l && (e = this._e[i]) && m.call(e, i, l) !== false);
|
190
|
+
|
191
|
+
return this;
|
192
|
+
}
|
193
|
+
|
194
|
+
/*
|
195
|
+
The map method allows multidimensional loops.
|
196
|
+
|
197
|
+
//map through and increase y every 3 entities.
|
198
|
+
|
199
|
+
re('draw').map(3, function(x, y){
|
200
|
+
this.x(x * width);
|
201
|
+
this.y(Y * height);
|
202
|
+
});
|
203
|
+
|
204
|
+
//so instead of getting this back
|
205
|
+
[e,e,e,e,e...]
|
206
|
+
|
207
|
+
//you will get this
|
208
|
+
[
|
209
|
+
[e,e,e],
|
210
|
+
[e,e,e],
|
211
|
+
[e,e,e]
|
212
|
+
...
|
213
|
+
]
|
214
|
+
|
215
|
+
returning false will break the loop
|
216
|
+
|
217
|
+
*/
|
218
|
+
p.map = function(w, method){
|
219
|
+
var x = 0;
|
220
|
+
var y = 0;
|
221
|
+
|
222
|
+
for(var i =0, l = this._e.length; i<l; i++){
|
223
|
+
|
224
|
+
if(method.call(this._e[i], x, y, i, l) == false) break;
|
225
|
+
|
226
|
+
x++;
|
227
|
+
|
228
|
+
if(x == w){
|
229
|
+
x = 0;
|
230
|
+
y++;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
/*
|
236
|
+
Returns an array of all components in the query.
|
237
|
+
*/
|
238
|
+
p.getComps = function(){
|
239
|
+
var l = [];
|
240
|
+
|
241
|
+
this.each(function(){
|
242
|
+
l.concat(this.getComps());
|
243
|
+
});
|
244
|
+
|
245
|
+
return l;
|
246
|
+
}
|
247
|
+
|
248
|
+
/*
|
249
|
+
Returns a random entity.
|
250
|
+
*/
|
251
|
+
p.random = function(){
|
252
|
+
return this._e[~~(Math.random()*this._e.length)];
|
253
|
+
}
|
254
|
+
|
255
|
+
/*
|
256
|
+
The pluck method returns all values from all entities in an array.
|
257
|
+
|
258
|
+
//will return all pos objs from all entities.
|
259
|
+
re('point').pluck('pos visible');
|
260
|
+
|
261
|
+
//if we echo...
|
262
|
+
|
263
|
+
[
|
264
|
+
{pos:0, visible:0}
|
265
|
+
...
|
266
|
+
]
|
267
|
+
|
268
|
+
*/
|
269
|
+
p.pluck = function(value){
|
270
|
+
var t = [];
|
271
|
+
|
272
|
+
var k = value.split(' ');
|
273
|
+
|
274
|
+
this.each(function(){
|
275
|
+
var o = {};
|
276
|
+
|
277
|
+
for(var p in k){
|
278
|
+
if(k.hasOwnProperty(p)){
|
279
|
+
o[k[p]] = this[k[p]];
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
t.push(o);
|
284
|
+
|
285
|
+
});
|
286
|
+
|
287
|
+
return t;
|
288
|
+
}
|
289
|
+
|
290
|
+
p.extend = function(obj, value){
|
291
|
+
this.each(function(){
|
292
|
+
this.extend(obj,value);
|
293
|
+
});
|
294
|
+
|
295
|
+
return this;
|
296
|
+
}
|
297
|
+
|
298
|
+
p.inherit = function(obj, value){
|
299
|
+
this.each(function(){
|
300
|
+
this.inherit(obj, value);
|
301
|
+
});
|
302
|
+
|
303
|
+
return this;
|
304
|
+
}
|
305
|
+
|
306
|
+
p.addComp = function(c){
|
307
|
+
|
308
|
+
this.each(function(ref){
|
309
|
+
this.addComp(c);
|
310
|
+
});
|
311
|
+
|
312
|
+
return this;
|
313
|
+
}
|
314
|
+
|
315
|
+
p.removeComp = function(c){
|
316
|
+
this.each(function(ref){
|
317
|
+
this.removeComp(c);
|
318
|
+
});
|
319
|
+
}
|
320
|
+
|
321
|
+
p.signal = function(type, method){
|
322
|
+
var p = arguments;
|
323
|
+
|
324
|
+
this.each(function(ref){
|
325
|
+
this.signal.apply(this, p);
|
326
|
+
});
|
327
|
+
|
328
|
+
return this;
|
329
|
+
}
|
330
|
+
|
331
|
+
p.length = function(){
|
332
|
+
return this._e.length;
|
333
|
+
}
|
334
|
+
|
335
|
+
/*
|
336
|
+
filters out entities that do not match credentials
|
337
|
+
|
338
|
+
//spawns all entities that are dead
|
339
|
+
re('2d health').filter(function(i){
|
340
|
+
|
341
|
+
if(this.health <= 0){
|
342
|
+
//keep entity
|
343
|
+
return true;
|
344
|
+
}
|
345
|
+
|
346
|
+
//remove entity
|
347
|
+
return false;
|
348
|
+
|
349
|
+
}).signal('spawn');
|
350
|
+
|
351
|
+
*/
|
352
|
+
p.filter = function(method){
|
353
|
+
|
354
|
+
var q = re();
|
355
|
+
var that = this;
|
356
|
+
|
357
|
+
this.each(function(i, l){
|
358
|
+
|
359
|
+
if(method.call(this, i, l)){
|
360
|
+
//add entity
|
361
|
+
q.push(this);
|
362
|
+
}
|
363
|
+
|
364
|
+
});
|
365
|
+
|
366
|
+
return q;
|
367
|
+
}
|
368
|
+
|
369
|
+
p.has = function(comp){
|
370
|
+
|
371
|
+
for(var i=0; i<this._e.length; i++){
|
372
|
+
if(!this._e.has(comp)){
|
373
|
+
return false;
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
return this;
|
378
|
+
}
|
379
|
+
|
380
|
+
p.dispose = function(){
|
381
|
+
|
382
|
+
this.each(function(){
|
383
|
+
|
384
|
+
this.dispose();
|
385
|
+
|
386
|
+
});
|
387
|
+
|
388
|
+
return this;
|
389
|
+
}
|
390
|
+
|
391
|
+
/*
|
392
|
+
Get specific entity from given index.
|
393
|
+
*/
|
394
|
+
p.get = function(index){
|
395
|
+
return this._e[index];
|
396
|
+
}
|
397
|
+
|
398
|
+
/*
|
399
|
+
Put entity into query array.
|
400
|
+
*/
|
401
|
+
p.put = function(entity){
|
402
|
+
|
403
|
+
this._e.push(entity);
|
404
|
+
|
405
|
+
return this;
|
406
|
+
}
|
407
|
+
|
408
|
+
re.query = q;
|
409
|
+
|
410
|
+
}(re));
|
@@ -0,0 +1,70 @@
|
|
1
|
+
/*
|
2
|
+
EntityJS Javascript Game Engine
|
3
|
+
Copyright 2011, Ben D'Angelo
|
4
|
+
http://entityjs.com
|
5
|
+
|
6
|
+
Licensed under MIT http://entityjs.com/license
|
7
|
+
|
8
|
+
*/
|
9
|
+
re = function(selector){
|
10
|
+
return new re.query(selector);
|
11
|
+
};
|
12
|
+
|
13
|
+
//automatically filled when compiled
|
14
|
+
re.version = "$VERSION";
|
15
|
+
|
16
|
+
//contains all entities
|
17
|
+
re._e = [];
|
18
|
+
//contains all components
|
19
|
+
re._c = {};
|
20
|
+
|
21
|
+
re.ready = function(r){
|
22
|
+
re.ready.c.push(r);
|
23
|
+
|
24
|
+
window.onload = function(){
|
25
|
+
for(var k in re.ready.c){
|
26
|
+
re.ready.c[k].call(re);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
};
|
30
|
+
re.ready.c = [];
|
31
|
+
|
32
|
+
/*
|
33
|
+
The $ method is used for selecting ids and tags.
|
34
|
+
*/
|
35
|
+
re.$ = function(s){
|
36
|
+
return re.$.c[s] = re.$.c[s] || (s.charAt(0) == '#') ? document.getElementById(s.substr(1)) : document.getElementsByTagName(s);
|
37
|
+
};
|
38
|
+
//caches dom queries
|
39
|
+
re.$.c = {};
|
40
|
+
|
41
|
+
re.$new = function(n){
|
42
|
+
return document.createElement(n);
|
43
|
+
};
|
44
|
+
|
45
|
+
/*
|
46
|
+
Special polyfills and object additions
|
47
|
+
*/
|
48
|
+
re.listener = function(t, c){
|
49
|
+
if(window.addEventListener){
|
50
|
+
window.addEventListener(t, c, true);
|
51
|
+
} else {
|
52
|
+
document.attachEvent('on'+t, c);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
Function.prototype.context = function(c){
|
57
|
+
var that = this;
|
58
|
+
return function(){ return that.apply(c, arguments); };
|
59
|
+
};
|
60
|
+
|
61
|
+
if(!Array.prototype.indexOf){
|
62
|
+
Array.prototype.indexOf = function(o){
|
63
|
+
for(var i=0; i<this.length; i++){
|
64
|
+
if(this[i]==o){
|
65
|
+
return i;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return -1;
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/*
|
2
|
+
The system component contains all information and references to the entity js engine.
|
3
|
+
Such as the canvas context, fps, start, stop, canvas.
|
4
|
+
|
5
|
+
You can add the component to entities for quick reference to variables.
|
6
|
+
|
7
|
+
FUTURE
|
8
|
+
-add entity extends to allow local usage.
|
9
|
+
-perhaps allow users to override the system class for their own custom usage. (new arrays of entities and components)
|
10
|
+
*/
|
11
|
+
re.c('system')
|
12
|
+
.inherit({
|
13
|
+
|
14
|
+
contextType:'2d',
|
15
|
+
|
16
|
+
clearColor:'#f9f9f9',
|
17
|
+
|
18
|
+
stepSize:0.03,
|
19
|
+
|
20
|
+
running:false,
|
21
|
+
|
22
|
+
sizeX:0,
|
23
|
+
sizeY:0
|
24
|
+
|
25
|
+
})
|
26
|
+
.extend({
|
27
|
+
|
28
|
+
clear:function(color){
|
29
|
+
|
30
|
+
if(color){
|
31
|
+
this.context.fillStyle = color;
|
32
|
+
this.context.fillRect(0, 0, this.sizeX, this.sizeY);
|
33
|
+
} else {
|
34
|
+
this.context.clearRect(0, 0, this.sizeX, this.sizeY);
|
35
|
+
}
|
36
|
+
|
37
|
+
return this;
|
38
|
+
},
|
39
|
+
|
40
|
+
start:function(){
|
41
|
+
if(!this.running){
|
42
|
+
this.running = true;
|
43
|
+
|
44
|
+
var that = this;
|
45
|
+
|
46
|
+
(function mainLoop(){
|
47
|
+
|
48
|
+
that.system_loop.call(that);
|
49
|
+
|
50
|
+
if(that.running){
|
51
|
+
that.requestAnimationFrame(mainLoop, that.canvas);
|
52
|
+
}
|
53
|
+
|
54
|
+
})();
|
55
|
+
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
return this;
|
60
|
+
},
|
61
|
+
|
62
|
+
loop:function(m){
|
63
|
+
|
64
|
+
this.system_loop = m;
|
65
|
+
|
66
|
+
return this;
|
67
|
+
},
|
68
|
+
|
69
|
+
stop:function(){
|
70
|
+
this.running = false;
|
71
|
+
return this;
|
72
|
+
},
|
73
|
+
|
74
|
+
init:function(canvasId, screen, contextType){
|
75
|
+
|
76
|
+
//add comps here because system is extendd earlier
|
77
|
+
this.addComp('polyfill ticker timestep');
|
78
|
+
|
79
|
+
//setup canvas
|
80
|
+
this.canvas = re.$(canvasId);
|
81
|
+
|
82
|
+
this.contextType = contextType || this.contextType;
|
83
|
+
|
84
|
+
this.context = this.canvas.getContext(this.contextType);
|
85
|
+
|
86
|
+
this.sizeX = this.canvas.width;
|
87
|
+
this.sizeY = this.canvas.height;
|
88
|
+
|
89
|
+
screen = screen || re.screen;
|
90
|
+
|
91
|
+
if(screen){
|
92
|
+
screen.sizeX = this.sizeX;
|
93
|
+
screen.sizeY = this.sizeY;
|
94
|
+
|
95
|
+
screen.regX = this.sizeX * 0.5;
|
96
|
+
screen.regY = this.sizeY * 0.5;
|
97
|
+
}
|
98
|
+
|
99
|
+
return this;
|
100
|
+
},
|
101
|
+
|
102
|
+
/*
|
103
|
+
Default main loop
|
104
|
+
*/
|
105
|
+
system_loop:function(){
|
106
|
+
|
107
|
+
this.timestep(this.tick(), function(){
|
108
|
+
//update
|
109
|
+
re._c.update.update.call(re._c.update, this, this.stepSize);
|
110
|
+
});
|
111
|
+
|
112
|
+
//clear
|
113
|
+
this.clear(this.clearColor);
|
114
|
+
|
115
|
+
re._c.draw.draw.call(re._c.draw, this);
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
})
|
120
|
+
.run(function(){
|
121
|
+
|
122
|
+
//create default system
|
123
|
+
re.system = re.sys = re.e('system');
|
124
|
+
|
125
|
+
});
|