entityjs 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -6
- data/.rspec +2 -0
- data/README.md +170 -49
- data/Rakefile +9 -0
- data/bin/entityjs +24 -14
- data/entityjs.gemspec +15 -9
- data/lib/entityjs/assets.rb +167 -0
- data/lib/entityjs/command.rb +52 -27
- data/lib/entityjs/commands/build.rb +128 -0
- data/lib/entityjs/commands/comp.rb +74 -0
- data/lib/entityjs/commands/font.rb +73 -0
- data/lib/entityjs/commands/new.rb +59 -0
- data/lib/entityjs/commands/server.rb +54 -0
- data/lib/entityjs/commands/templates.rb +28 -0
- data/lib/entityjs/commands/test.rb +69 -0
- data/lib/entityjs/config.rb +130 -0
- data/lib/entityjs/dirc.rb +184 -0
- data/lib/entityjs/parsers/parse_tmx.rb +41 -0
- data/lib/entityjs/parsers/parse_xml.rb +39 -0
- data/lib/entityjs/version.rb +1 -1
- data/lib/entityjs.rb +53 -0
- data/license.txt +1 -1
- data/public/play.html +122 -0
- data/public/qunit/qunit.css +226 -0
- data/public/qunit/qunit.entity.js +190 -0
- data/public/qunit/qunit.input.js +200 -0
- data/public/qunit/qunit.js +1598 -0
- data/public/qunit/qunit.mock.js +97 -0
- data/public/tests.html +45 -0
- data/spec/javascripts/helpers/accept.png +0 -0
- data/spec/javascripts/helpers/alligator.mp3 +0 -0
- data/spec/javascripts/helpers/alligator.ogg +0 -0
- data/spec/javascripts/helpers/canvas.js +15 -0
- data/spec/javascripts/helpers/entityunit.js +50 -0
- data/spec/javascripts/helpers/factories.js +11 -0
- data/spec/javascripts/helpers/jquery-1.7.1.min.js +4 -0
- data/spec/javascripts/src/core/comp_spec.js +145 -0
- data/spec/javascripts/src/core/entity_spec.js +324 -0
- data/spec/javascripts/src/core/load_spec.js +71 -0
- data/spec/javascripts/src/core/query_spec.js +157 -0
- data/spec/javascripts/src/core/re_spec.js +61 -0
- data/spec/javascripts/src/core/system_spec.js +41 -0
- data/spec/javascripts/src/cycle/draw_spec.js +106 -0
- data/spec/javascripts/src/cycle/tick_spec.js +20 -0
- data/spec/javascripts/src/cycle/update_spec.js +86 -0
- data/spec/javascripts/src/display/align_spec.js +43 -0
- data/spec/javascripts/src/display/circle_spec.js +26 -0
- data/spec/javascripts/src/display/group_spec.js +7 -0
- data/spec/javascripts/src/display/image_spec.js +32 -0
- data/spec/javascripts/src/display/imgtext_spec.js +32 -0
- data/spec/javascripts/src/display/rect_spec.js +13 -0
- data/spec/javascripts/src/display/screen_spec.js +47 -0
- data/spec/javascripts/src/display/sprite_spec.js +28 -0
- data/spec/javascripts/src/display/text_spec.js +30 -0
- data/spec/javascripts/src/input/keyboard_spec.js +67 -0
- data/spec/javascripts/src/input/mouse_spec.js +133 -0
- data/spec/javascripts/src/input/pressed_spec.js +31 -0
- data/spec/javascripts/src/math/bisect_spec.js +59 -0
- data/spec/javascripts/src/math/body_spec.js +30 -0
- data/spec/javascripts/src/math/drag_spec.js +38 -0
- data/spec/javascripts/src/math/force_spec.js +134 -0
- data/spec/javascripts/src/math/hit_spec.js +28 -0
- data/spec/javascripts/src/math/hitmap_spec.js +52 -0
- data/spec/javascripts/src/math/limit_spec.js +35 -0
- data/spec/javascripts/src/math/point_spec.js +57 -0
- data/spec/javascripts/src/math/tile_spec.js +78 -0
- data/spec/javascripts/src/media/sound_spec.js +40 -0
- data/spec/javascripts/src/pattern/automap_spec.js +93 -0
- data/spec/javascripts/src/pattern/flicker_spec.js +66 -0
- data/spec/javascripts/src/pattern/timestep_spec.js +23 -0
- data/spec/javascripts/src/save/storage_spec.js +37 -0
- data/spec/javascripts/src/util/log_spec.js +9 -0
- data/spec/javascripts/src/util/polyfill_spec.js +13 -0
- data/spec/javascripts/src/util/random_spec.js +33 -0
- data/spec/javascripts/src/util/scene_spec.js +52 -0
- data/spec/javascripts/src/util/sheet_spec.js +25 -0
- data/spec/javascripts/src/util/support_spec.js +17 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/javascripts/support/jasmine_config.rb +32 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/lib/entityjs/assets_spec.rb +216 -0
- data/spec/lib/entityjs/command_spec.rb +53 -0
- data/spec/lib/entityjs/commands/build_spec.rb +69 -0
- data/spec/lib/entityjs/commands/comp_spec.rb +45 -0
- data/spec/lib/entityjs/commands/font_spec.rb +7 -0
- data/spec/lib/entityjs/commands/new_spec.rb +20 -0
- data/spec/lib/entityjs/commands/templates_spec.rb +9 -0
- data/spec/lib/entityjs/commands/test_spec.rb +31 -0
- data/spec/lib/entityjs/config_spec.rb +19 -0
- data/spec/lib/entityjs/dirc_spec.rb +83 -0
- data/spec/lib/entityjs/version_spec.rb +9 -0
- data/spec/spec_helper.rb +21 -3
- data/spec/support/factories.rb +19 -0
- data/spec/support/mygame.rb +11 -0
- data/src/core/comp.js +318 -0
- data/src/core/entity.js +549 -0
- data/src/core/load.js +242 -0
- data/src/core/query.js +354 -0
- data/src/core/re.js +74 -0
- data/src/core/system.js +121 -0
- data/src/cycle/draw.js +178 -0
- data/src/cycle/tick.js +25 -0
- data/src/{entityjs/cycle → cycle}/tween.js +60 -60
- data/src/{entityjs/cycle → cycle}/update.js +86 -85
- data/src/{entityjs/cycle → cycle}/wait.js +22 -21
- data/src/{entityjs/cycle → cycle}/worker.js +8 -8
- data/src/display/align.js +45 -0
- data/src/display/circle.js +33 -0
- data/src/{entityjs/display → display}/group.js +62 -62
- data/src/display/image.js +35 -0
- data/src/display/imgtext.js +102 -0
- data/src/{entityjs/display → display}/rect.js +18 -18
- data/src/display/screen.js +57 -0
- data/src/display/sprite.js +54 -0
- data/src/display/text.js +44 -0
- data/src/{entityjs/input → input}/keyboard.js +152 -150
- data/src/input/mouse.js +111 -0
- data/src/input/pressed.js +41 -0
- data/src/{entityjs/input → input}/touch.js +24 -28
- data/src/math/bisect.js +84 -0
- data/src/math/body.js +70 -0
- data/src/{entityjs/math → math}/drag.js +44 -38
- data/src/math/force.js +143 -0
- data/src/math/hit.js +32 -0
- data/src/math/hitmap.js +167 -0
- data/src/math/limit.js +37 -0
- data/src/math/point.js +40 -0
- data/src/math/tile.js +109 -0
- data/src/media/channel.js +93 -0
- data/src/{entityjs/media → media}/playlist.js +4 -4
- data/src/media/sound.js +114 -0
- data/src/{entityjs/net → net}/socket.js +51 -51
- data/src/pattern/automap.js +133 -0
- data/src/{entityjs/pattern → pattern}/flicker.js +206 -213
- data/src/pattern/timestep.js +31 -0
- data/src/{entityjs/save → save}/database.js +6 -6
- data/src/{entityjs/save → save}/storage.js +47 -56
- data/src/{entityjs/util → util}/log.js +17 -25
- data/src/{entityjs/util → util}/polyfill.js +24 -24
- data/src/util/random.js +20 -0
- data/src/util/scene.js +102 -0
- data/src/util/sheet.js +35 -0
- data/src/{entityjs/util → util}/support.js +109 -132
- data/{examples/keys → templates/arrow_keys/assets/images}/arrow.png +0 -0
- data/templates/arrow_keys/config.yml +22 -0
- data/templates/arrow_keys/readme.txt +9 -0
- data/templates/arrow_keys/scripts/display/arrow.js +69 -0
- data/templates/arrow_keys/scripts/init.js +10 -0
- data/templates/arrow_keys/scripts/input/controls.js +35 -0
- data/templates/arrow_keys/scripts/scenes/home.js +20 -0
- data/templates/arrow_keys/scripts/scenes/load.js +57 -0
- data/templates/arrow_keys/tests/display/arrow_test.js +29 -0
- data/templates/arrow_keys/tests/init_test.js +4 -0
- data/templates/arrow_keys/tests/input/controls_test.js +32 -0
- data/templates/arrow_keys/tests/scenes/home_test.js +0 -0
- data/templates/arrow_keys/tests/scenes/load_test.js +16 -0
- data/templates/blank/config.yml +22 -0
- data/templates/blank/readme.txt +79 -0
- data/templates/platform/assets/images/bit.png +0 -0
- data/templates/platform/assets/images/hero.png +0 -0
- data/templates/platform/assets/images/items.png +0 -0
- data/templates/platform/assets/images/tiles.png +0 -0
- data/templates/platform/assets/levels/level1.tmx +44 -0
- data/templates/platform/assets/sounds/coin.mp3 +0 -0
- data/templates/platform/assets/sounds/coin.ogg +0 -0
- data/templates/platform/config.yml +22 -0
- data/templates/platform/readme.txt +87 -0
- data/templates/platform/scripts/display/bit.js +12 -0
- data/templates/platform/scripts/display/hero.js +77 -0
- data/templates/platform/scripts/display/tile.js +2 -0
- data/templates/platform/scripts/display/tsprite.js +17 -0
- data/templates/platform/scripts/init.js +7 -0
- data/templates/platform/scripts/items/coin.js +27 -0
- data/templates/platform/scripts/items/item.js +41 -0
- data/templates/platform/scripts/items/spring.js +25 -0
- data/templates/platform/scripts/scenes/home.js +10 -0
- data/templates/platform/scripts/scenes/load.js +27 -0
- data/templates/platform/scripts/scenes/play.js +31 -0
- data/templates/platform/scripts/util/counter.js +34 -0
- data/templates/platform/scripts/util/level.js +84 -0
- data/templates/platform/tests/display/bit_test.js +7 -0
- data/templates/platform/tests/display/hero_test.js +73 -0
- data/templates/platform/tests/display/tile_test.js +7 -0
- data/templates/platform/tests/display/tsprite_test.js +8 -0
- data/templates/platform/tests/factories.js +30 -0
- data/templates/platform/tests/items/coin_test.js +28 -0
- data/templates/platform/tests/items/item_test.js +36 -0
- data/templates/platform/tests/items/spring_test.js +21 -0
- data/templates/platform/tests/scenes/home_test.js +9 -0
- data/templates/platform/tests/scenes/load_test.js +11 -0
- data/templates/platform/tests/scenes/play_test.js +15 -0
- data/templates/platform/tests/util/counter_test.js +9 -0
- data/templates/platform/tests/util/level_test.js +29 -0
- metadata +249 -97
- data/build/build_debug.bat +0 -1
- data/build/build_min.bat +0 -1
- data/build/config.php +0 -64
- data/build/debug.php +0 -48
- data/build/files.php +0 -74
- data/build/jsmin.php +0 -376
- data/build/min.php +0 -50
- data/changelog.txt +0 -53
- data/examples/keys/keys.html +0 -59
- data/examples/keys/keys.js +0 -148
- data/examples/mouse/mouse.html +0 -58
- data/examples/mouse/mouse.js +0 -60
- data/examples/scenes/home.png +0 -0
- data/examples/scenes/scenes.html +0 -55
- data/examples/scenes/scenes.js +0 -134
- 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 +0 -56
- data/examples/sounds/sounds.js +0 -44
- data/examples/style/background.png +0 -0
- data/examples/style/sheet.css +0 -762
- data/examples/tiles/tiles.html +0 -56
- data/examples/tiles/tiles.js +0 -85
- data/examples/tiles/tiles.png +0 -0
- data/lib/blank/config.js +0 -4
- data/lib/blank/config.yml +0 -21
- data/lib/blank/home.js +0 -11
- data/lib/blank/init.js +0 -7
- data/lib/blank/load.js +0 -21
- data/lib/blank/play.html +0 -29
- data/lib/entity.debug.js +0 -52
- data/lib/entity.min.js +0 -184
- data/lib/entityjs/comp.rb +0 -11
- data/lib/entityjs/game.rb +0 -93
- data/lib/entityjs/min.rb +0 -11
- data/lib/entityjs/refresh.rb +0 -14
- data/spec/lib/entityjs/game_spec.rb +0 -11
- data/src/entityjs/core/component.js +0 -306
- data/src/entityjs/core/entity.js +0 -516
- data/src/entityjs/core/load.js +0 -224
- data/src/entityjs/core/query.js +0 -410
- data/src/entityjs/core/re.js +0 -70
- data/src/entityjs/core/system.js +0 -125
- data/src/entityjs/cycle/draw.js +0 -185
- data/src/entityjs/cycle/ticker.js +0 -27
- data/src/entityjs/display/anchor.js +0 -53
- data/src/entityjs/display/bitfont.js +0 -93
- data/src/entityjs/display/bitmap.js +0 -37
- data/src/entityjs/display/circle.js +0 -30
- data/src/entityjs/display/font.js +0 -41
- data/src/entityjs/display/screen.js +0 -46
- data/src/entityjs/display/sprite.js +0 -37
- data/src/entityjs/input/mouse.js +0 -123
- data/src/entityjs/input/pressed.js +0 -81
- data/src/entityjs/math/bind.js +0 -76
- data/src/entityjs/math/bisect.js +0 -69
- data/src/entityjs/math/body.js +0 -39
- data/src/entityjs/math/hitmap.js +0 -165
- data/src/entityjs/math/hittest.js +0 -26
- data/src/entityjs/math/physics.js +0 -142
- data/src/entityjs/math/point.js +0 -57
- data/src/entityjs/math/tile.js +0 -91
- data/src/entityjs/media/channel.js +0 -93
- data/src/entityjs/media/sound.js +0 -110
- data/src/entityjs/pattern/arraymap.js +0 -89
- data/src/entityjs/pattern/timestep.js +0 -34
- data/src/entityjs/util/random.js +0 -38
- data/src/entityjs/util/scene.js +0 -101
- data/src/entityjs/util/sheet.js +0 -51
data/src/entityjs/math/tile.js
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The tile component adds tile positioning functions and helper functions for tile based games.
|
3
|
-
*/
|
4
|
-
re.tile = re.c('tile')
|
5
|
-
.global({
|
6
|
-
sizeX:40,
|
7
|
-
sizeY:40,
|
8
|
-
|
9
|
-
roundX:function(x, size){
|
10
|
-
if(arguments.length == 1){
|
11
|
-
size = re.tile.sizeX;
|
12
|
-
}
|
13
|
-
return re.tile.roundTileX(x) * size;
|
14
|
-
},
|
15
|
-
|
16
|
-
roundY:function(y, size){
|
17
|
-
if(arguments.length == 1){
|
18
|
-
size = re.tile.sizeY;
|
19
|
-
}
|
20
|
-
return re.tile.roundTileY(y) * size;
|
21
|
-
},
|
22
|
-
|
23
|
-
roundTileX:function(x, size){
|
24
|
-
if(arguments.length == 1){
|
25
|
-
size = re.tile.sizeX;
|
26
|
-
}
|
27
|
-
return Math.round((x - size*0.5)/size);
|
28
|
-
},
|
29
|
-
|
30
|
-
roundTileY:function(y, size){
|
31
|
-
if(arguments.length == 1){
|
32
|
-
size = re.tile.sizeY;
|
33
|
-
}
|
34
|
-
return Math.round((y - size * 0.5)/size);
|
35
|
-
}
|
36
|
-
|
37
|
-
})
|
38
|
-
.inherit({
|
39
|
-
|
40
|
-
posX:0,
|
41
|
-
posY:0
|
42
|
-
|
43
|
-
})
|
44
|
-
.init(function(){
|
45
|
-
|
46
|
-
if(!this.sizeX)
|
47
|
-
this.sizeX = re.tile.sizeX;
|
48
|
-
|
49
|
-
if(!this.sizeY)
|
50
|
-
this.sizeY = re.tile.sizeY;
|
51
|
-
|
52
|
-
})
|
53
|
-
.extend({
|
54
|
-
|
55
|
-
setTileFromPoint:function(x, y){
|
56
|
-
this.posX = re.tile.roundX(x);
|
57
|
-
this.posY = re.tile.roundY(y);
|
58
|
-
|
59
|
-
return this;
|
60
|
-
},
|
61
|
-
|
62
|
-
setTile:function(xt, yt){
|
63
|
-
this.setTileX(xt);
|
64
|
-
this.setTileY(yt);
|
65
|
-
|
66
|
-
return this;
|
67
|
-
},
|
68
|
-
|
69
|
-
setTileX:function(value){
|
70
|
-
this.posX = Math.floor(value * this.sizeX);
|
71
|
-
|
72
|
-
return this;
|
73
|
-
},
|
74
|
-
|
75
|
-
getTileX:function(){
|
76
|
-
return Math.floor(this.posX / this.sizeX);
|
77
|
-
},
|
78
|
-
|
79
|
-
setTileY:function(value){
|
80
|
-
|
81
|
-
this.posY = Math.floor(value * this.sizeY);
|
82
|
-
|
83
|
-
return this;
|
84
|
-
},
|
85
|
-
|
86
|
-
getTileY:function(){
|
87
|
-
|
88
|
-
return Math.floor(this.posY / this.sizeY);
|
89
|
-
}
|
90
|
-
|
91
|
-
});
|
@@ -1,93 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The channel component allows you to play a sound component more than
|
3
|
-
once at the sametime. This is useful for shooting or fast games.
|
4
|
-
|
5
|
-
//create a new channel
|
6
|
-
re.e('channel attack.sfx')
|
7
|
-
.play()
|
8
|
-
.play()
|
9
|
-
.play();
|
10
|
-
|
11
|
-
//extension sfx is created for every
|
12
|
-
//sound loaded regards of type
|
13
|
-
|
14
|
-
//TODO
|
15
|
-
|
16
|
-
//add more channels
|
17
|
-
|
18
|
-
//cloning glitch fix
|
19
|
-
document.body.appendChild(s);
|
20
|
-
|
21
|
-
s.addEventListener('canplaythrough', function(e){
|
22
|
-
|
23
|
-
//multiple channels will allow the sound to be played more at the sametime.
|
24
|
-
//this will load the sound multiple times sadly FIX
|
25
|
-
for(var i=0; i<re.load.maxChannels-1; i++){
|
26
|
-
channels.push(s.cloneNode(true));
|
27
|
-
}
|
28
|
-
|
29
|
-
if(that._p){
|
30
|
-
that._p.call(that, that.current, that.total, a);
|
31
|
-
}
|
32
|
-
|
33
|
-
if(that.current >= that.total){
|
34
|
-
|
35
|
-
if(that._s){
|
36
|
-
that._s.call(that, that.assets);
|
37
|
-
}
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
}, false);
|
42
|
-
*//*
|
43
|
-
re.channel = re.c('channel')
|
44
|
-
.require('sound')
|
45
|
-
.inherit({
|
46
|
-
volume:1,
|
47
|
-
max:3
|
48
|
-
})
|
49
|
-
.extend({
|
50
|
-
|
51
|
-
play:function(loop){
|
52
|
-
if(!this.channels || !re.sound.enabled) return this;
|
53
|
-
|
54
|
-
var c;
|
55
|
-
for(var i=0; i<this.channels.length; i++){
|
56
|
-
|
57
|
-
c = this.channels[i];
|
58
|
-
if(c.ended || !c.currentTime){
|
59
|
-
//play new channel
|
60
|
-
c.play();
|
61
|
-
break;
|
62
|
-
} else if(i == this.channels[i].length-1){
|
63
|
-
c.currentTime = 0;
|
64
|
-
c.play();
|
65
|
-
}
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
if(loop){
|
70
|
-
|
71
|
-
var l = 0;
|
72
|
-
|
73
|
-
c.addEventListener('ended', function(){
|
74
|
-
|
75
|
-
if(loop == -1 || l >= loop){
|
76
|
-
this.currentTime = 0;
|
77
|
-
l++;
|
78
|
-
}
|
79
|
-
|
80
|
-
}, false);
|
81
|
-
|
82
|
-
}
|
83
|
-
|
84
|
-
return this;
|
85
|
-
},
|
86
|
-
|
87
|
-
stop:function(){
|
88
|
-
|
89
|
-
//stop all channels
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
});*/
|
data/src/entityjs/media/sound.js
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The sound component utilizes the new HTML5 to play sound effects in the web browser.
|
3
|
-
It is reccommended to load two sound codecs OGG and AAC because not every browser supports
|
4
|
-
all sound codecs at this time.
|
5
|
-
|
6
|
-
//load a sound
|
7
|
-
re.load('run.ogg run.aac');
|
8
|
-
//BAD this will load both sounds. Even if the browser might not support one
|
9
|
-
|
10
|
-
//GOOD. load just one codec of the sound
|
11
|
-
var codec;
|
12
|
-
if(re.support('ogg')){
|
13
|
-
codec = 'ogg';
|
14
|
-
} else if(re.support('aac')){
|
15
|
-
codec = 'aac';
|
16
|
-
}
|
17
|
-
|
18
|
-
re.load('run.'+codec');
|
19
|
-
|
20
|
-
//create sound
|
21
|
-
re.e('sound run.'+codec);
|
22
|
-
|
23
|
-
//that is a pain, so a helper method has been created
|
24
|
-
re('sound run.'+re.support('ogg', 'aac'));
|
25
|
-
|
26
|
-
Its reccomended to save the supported codec somewhere globaly
|
27
|
-
//like so...
|
28
|
-
re.codec = re.support('ogg', 'aac');
|
29
|
-
|
30
|
-
re.load('run.'+re.codec);
|
31
|
-
|
32
|
-
re.e('run.'+re.codec);
|
33
|
-
|
34
|
-
WARNING: Because the sound component has generic
|
35
|
-
method names stop, play, watchout for overwrites.
|
36
|
-
|
37
|
-
Sound Tip
|
38
|
-
//find all sounds in game and play them all!
|
39
|
-
re('sound').method('play');
|
40
|
-
|
41
|
-
|
42
|
-
*/
|
43
|
-
re.sound = re.c('sound')
|
44
|
-
.global({
|
45
|
-
|
46
|
-
enabled:true
|
47
|
-
|
48
|
-
})
|
49
|
-
.namespace({
|
50
|
-
|
51
|
-
hasEvent:false,
|
52
|
-
loops:0
|
53
|
-
|
54
|
-
})
|
55
|
-
.extend({
|
56
|
-
|
57
|
-
play:function(loop){
|
58
|
-
if(!this.sound || !re.sound.enabled) return this;
|
59
|
-
|
60
|
-
var c = this.sound;
|
61
|
-
var that = this;
|
62
|
-
|
63
|
-
c.currentTime = 0;
|
64
|
-
|
65
|
-
c.play();
|
66
|
-
|
67
|
-
if(loop){
|
68
|
-
|
69
|
-
this.sound_loops = 0;
|
70
|
-
|
71
|
-
if(!this.sound_hasEvent){
|
72
|
-
this.sound_hasEvent = true;
|
73
|
-
|
74
|
-
c.addEventListener('ended', function(){
|
75
|
-
|
76
|
-
that.signal('sounded', that.sound_loops, loop);
|
77
|
-
|
78
|
-
if(loop == -1 || that.sound_loops < loop){
|
79
|
-
c.currentTime = 0;
|
80
|
-
that.sound_loops++;
|
81
|
-
}
|
82
|
-
|
83
|
-
}, false);
|
84
|
-
}
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
return this;
|
89
|
-
},
|
90
|
-
|
91
|
-
resume:function(){
|
92
|
-
this.sound.play();
|
93
|
-
return this;
|
94
|
-
},
|
95
|
-
|
96
|
-
pause:function(){
|
97
|
-
this.sound.pause();
|
98
|
-
|
99
|
-
return this;
|
100
|
-
},
|
101
|
-
|
102
|
-
currentTime:function(){
|
103
|
-
return this.sound.currentTime;
|
104
|
-
},
|
105
|
-
|
106
|
-
ended:function(){
|
107
|
-
return this.sound.ended;
|
108
|
-
}
|
109
|
-
|
110
|
-
});
|
@@ -1,89 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The arraymap component creates an auto expandable two-dimensional array.
|
3
|
-
*/
|
4
|
-
re.c('arraymap')
|
5
|
-
.inherit({
|
6
|
-
lengthX:0,
|
7
|
-
lengthY:0
|
8
|
-
})
|
9
|
-
.extend({
|
10
|
-
/*map:null,
|
11
|
-
size:null,*/
|
12
|
-
value:0,
|
13
|
-
|
14
|
-
set:function(x, y, value){
|
15
|
-
|
16
|
-
//increate y length
|
17
|
-
while(y >= this.map.length){
|
18
|
-
var m = new Array(this.map[0]);
|
19
|
-
|
20
|
-
for(var l in m){
|
21
|
-
m[l] = this.value;
|
22
|
-
}
|
23
|
-
|
24
|
-
this.map.push(m);
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
//increase x length
|
29
|
-
while(x >= this.map[this.map.length-1].length){
|
30
|
-
|
31
|
-
for(var k=0; k<this.map.length; k++){
|
32
|
-
this.map[k].push(this.value);
|
33
|
-
}
|
34
|
-
|
35
|
-
}
|
36
|
-
|
37
|
-
this.lengthX = this.map[y].length;
|
38
|
-
this.lengthY = this.map.length;
|
39
|
-
|
40
|
-
this.map[y][x] = value;
|
41
|
-
|
42
|
-
return this;
|
43
|
-
},
|
44
|
-
|
45
|
-
within:function(x, y){
|
46
|
-
|
47
|
-
if(y < 0 || y >= this.lengthY || x < 0 || x >= this.lengthX){
|
48
|
-
return false;
|
49
|
-
}
|
50
|
-
return true;
|
51
|
-
},
|
52
|
-
|
53
|
-
get:function(x, y){
|
54
|
-
if(this.within(x,y)){
|
55
|
-
return this.map[y][x];
|
56
|
-
}
|
57
|
-
return null;
|
58
|
-
},
|
59
|
-
|
60
|
-
copy:function(a){
|
61
|
-
|
62
|
-
for(var y=0; y<a.length; y++){
|
63
|
-
for(var x=0; x<a[0].length; x++){
|
64
|
-
this.set(x, y, a[y][x]);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
return this;
|
69
|
-
},
|
70
|
-
|
71
|
-
copyByRef:function(m){
|
72
|
-
|
73
|
-
this.map = m;
|
74
|
-
|
75
|
-
if(m.length > 0){
|
76
|
-
this.lengthX = m[0].length;
|
77
|
-
} else {
|
78
|
-
this.lengthX = 0;
|
79
|
-
}
|
80
|
-
|
81
|
-
this.lengthY = m.length;
|
82
|
-
|
83
|
-
return this;
|
84
|
-
}
|
85
|
-
|
86
|
-
})
|
87
|
-
.init(function(){
|
88
|
-
this.map = [];
|
89
|
-
});
|
@@ -1,34 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
|
3
|
-
|
4
|
-
re.e('timestep')
|
5
|
-
.timestep(progress, function(){
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
});
|
10
|
-
*/
|
11
|
-
|
12
|
-
re.c('timestep')
|
13
|
-
.inherit({
|
14
|
-
|
15
|
-
stepProgress:0,
|
16
|
-
stepSize:0.3
|
17
|
-
|
18
|
-
})
|
19
|
-
.extend({
|
20
|
-
|
21
|
-
timestep:function(progress, callback, context){
|
22
|
-
|
23
|
-
this.stepProgress += progress;
|
24
|
-
|
25
|
-
while(this.stepProgress >= this.stepSize){
|
26
|
-
|
27
|
-
callback.call((context)?context:this);
|
28
|
-
|
29
|
-
this.stepProgress -= this.stepSize;
|
30
|
-
}
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
})
|
data/src/entityjs/util/random.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The random component implements two helper methods for calculating random numbers.
|
3
|
-
|
4
|
-
r = re.e('random');
|
5
|
-
|
6
|
-
r.random() // 0 - 1
|
7
|
-
r.random(10) // 0 - 9
|
8
|
-
r.random(10, 30) // 10 - 30
|
9
|
-
|
10
|
-
randomInt rounds numbers to whole
|
11
|
-
*/
|
12
|
-
re.c('random')
|
13
|
-
.extend({
|
14
|
-
|
15
|
-
random:function(max, min){
|
16
|
-
switch(arguments.length){
|
17
|
-
case 0:
|
18
|
-
return Math.random();
|
19
|
-
case 1:
|
20
|
-
return Math.random() * max;
|
21
|
-
case 2:
|
22
|
-
return Math.random() * (max - min + 1) + min;
|
23
|
-
}
|
24
|
-
},
|
25
|
-
|
26
|
-
randomInt:function(max, min){
|
27
|
-
return Math.floor(this.random.apply(this, arguments));
|
28
|
-
}
|
29
|
-
|
30
|
-
})
|
31
|
-
.run(function(){
|
32
|
-
var b = re.e('random');
|
33
|
-
|
34
|
-
re.random = b.random;
|
35
|
-
re.randomInt = b.randomInt;
|
36
|
-
|
37
|
-
b.dispose();
|
38
|
-
});
|
data/src/entityjs/util/scene.js
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
|
2
|
-
/*
|
3
|
-
Goes to an other scene in the game. This calls the scene method with a possible object argument.
|
4
|
-
|
5
|
-
Scenes are a helpful way to organize stages of a game.
|
6
|
-
|
7
|
-
//create scene
|
8
|
-
re.scene('game')
|
9
|
-
.enter(function(data){
|
10
|
-
|
11
|
-
//remove all 2d elements
|
12
|
-
re('2d').dispose();
|
13
|
-
|
14
|
-
loadLevel(data.level);
|
15
|
-
|
16
|
-
});
|
17
|
-
|
18
|
-
//go to scene
|
19
|
-
re.scene('game', {tiles:[]} );
|
20
|
-
|
21
|
-
//delete a scene
|
22
|
-
re.scene('-home');
|
23
|
-
|
24
|
-
//combine delete home goto title sceen
|
25
|
-
re.scene('-home title');
|
26
|
-
*/
|
27
|
-
re.scene = function(title){
|
28
|
-
var s = re.c('scene');
|
29
|
-
|
30
|
-
//delete scene
|
31
|
-
if(title.charAt(0) == '-'){
|
32
|
-
|
33
|
-
delete s._scenes[title.substr(1)];
|
34
|
-
|
35
|
-
return s;
|
36
|
-
|
37
|
-
} else if(s._scenes[title]){
|
38
|
-
//go to scene
|
39
|
-
|
40
|
-
var current = arguments.callee.current;
|
41
|
-
|
42
|
-
//call exit
|
43
|
-
var t = s._scenes[current];
|
44
|
-
if(t && typeof t.scene_exit == 'function'){
|
45
|
-
t.scene_exit.call(t, title);
|
46
|
-
}
|
47
|
-
|
48
|
-
arguments.callee.current = title;
|
49
|
-
s.curent = title;
|
50
|
-
|
51
|
-
t = s._scenes[title];
|
52
|
-
|
53
|
-
if(typeof t.scene_enter == 'function'){
|
54
|
-
t.scene_enter.apply(t, Array.prototype.slice.call(arguments, 1));
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
} else {
|
59
|
-
|
60
|
-
//add scene
|
61
|
-
re.e('scene:'+title);
|
62
|
-
}
|
63
|
-
|
64
|
-
return s._scenes[title];
|
65
|
-
};
|
66
|
-
|
67
|
-
re.c('scene')
|
68
|
-
.global({
|
69
|
-
|
70
|
-
_scenes:{}
|
71
|
-
|
72
|
-
})
|
73
|
-
.init(function(c, title){
|
74
|
-
|
75
|
-
c._scenes[title] = this;
|
76
|
-
this.sceneName = title;
|
77
|
-
|
78
|
-
})
|
79
|
-
.dispose(function(c){
|
80
|
-
|
81
|
-
delete c._scenes[this.sceneName];
|
82
|
-
|
83
|
-
})
|
84
|
-
.extend({
|
85
|
-
|
86
|
-
enter:function(m){
|
87
|
-
this.scene_enter = m;
|
88
|
-
|
89
|
-
return this;
|
90
|
-
},
|
91
|
-
|
92
|
-
exit:function(m){
|
93
|
-
this.scene_exit = m;
|
94
|
-
|
95
|
-
return this;
|
96
|
-
},
|
97
|
-
|
98
|
-
scene:function(){
|
99
|
-
return re.scene.apply(this, arguments);
|
100
|
-
}
|
101
|
-
});
|
data/src/entityjs/util/sheet.js
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The sheet component converts a each frame of a sprite sheet into their own components.
|
3
|
-
*/
|
4
|
-
re.c('sheet')
|
5
|
-
.global({
|
6
|
-
|
7
|
-
sheet:function(map, padX, padY, sizeX, sizeY){
|
8
|
-
|
9
|
-
var frameWidth = sizeX || re.tile.sizeX;
|
10
|
-
var frameHeight = sizeY || re.tile.sizeY;
|
11
|
-
|
12
|
-
if(padX){
|
13
|
-
frameWidth += padX;
|
14
|
-
}
|
15
|
-
|
16
|
-
if(padY){
|
17
|
-
frameHeight += padY;
|
18
|
-
}
|
19
|
-
|
20
|
-
//create new sprites for sheet
|
21
|
-
|
22
|
-
//save frame positions from map
|
23
|
-
var x;
|
24
|
-
var y;
|
25
|
-
|
26
|
-
for(var p in map){
|
27
|
-
x = map[p][0] || 0;
|
28
|
-
y = map[p][1] || 0;
|
29
|
-
|
30
|
-
re.c(p)
|
31
|
-
.require('sprite')
|
32
|
-
.extend({
|
33
|
-
frame:{x:x, y:y},
|
34
|
-
size:{x:frameWidth, y:frameHeight},
|
35
|
-
bitmap:this.bitmap
|
36
|
-
});
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
return this;
|
41
|
-
}
|
42
|
-
|
43
|
-
})
|
44
|
-
.require('tile')
|
45
|
-
.extend({
|
46
|
-
|
47
|
-
sheet:re.sheet
|
48
|
-
|
49
|
-
});
|
50
|
-
|
51
|
-
re.sheet = re.c('sheet').sheet;
|