entityjs 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -14
- data/entityjs.gemspec +1 -0
- data/lib/entityjs/assets.rb +13 -163
- data/lib/entityjs/command.rb +5 -2
- data/lib/entityjs/commands/build.rb +63 -23
- data/lib/entityjs/commands/eunit.rb +44 -0
- data/lib/entityjs/commands/release.rb +1 -1
- data/lib/entityjs/commands/server.rb +19 -4
- data/lib/entityjs/compile.rb +152 -0
- data/lib/entityjs/config.rb +8 -0
- data/lib/entityjs/dirc.rb +70 -17
- data/lib/entityjs/page.rb +106 -0
- data/lib/entityjs/parsers/parse_coffee.rb +12 -0
- data/lib/entityjs/version.rb +1 -1
- data/lib/entityjs.rb +18 -4
- data/public/qunit/qunit.css +9 -3
- data/public/qunit/qunit.entity.js +113 -31
- data/public/qunit/qunit.js +296 -235
- data/public/qunit/qunit.mock.js +54 -2
- data/public/tests.html +0 -15
- data/spec/javascripts/src/cycle/tween_spec.js +59 -0
- data/spec/javascripts/src/display/screen_spec.js +0 -15
- data/spec/javascripts/src/display/text_spec.js +4 -0
- data/spec/javascripts/src/input/mouse_spec.js +18 -18
- data/spec/javascripts/src/input/preventdefault_spec.js +14 -0
- data/spec/javascripts/src/math/drag_spec.js +2 -2
- data/spec/javascripts/src/math/hit_spec.js +24 -0
- data/spec/javascripts/src/math/point_spec.js +3 -3
- data/spec/javascripts/src/math/tile_spec.js +1 -1
- data/spec/javascripts/src/media/sound_spec.js +1 -1
- data/spec/javascripts/src/pattern/automap_spec.js +3 -3
- data/spec/javascripts/src/pattern/flicker_spec.js +2 -1
- data/spec/javascripts/src/util/random_spec.js +17 -0
- data/spec/javascripts/src/util/scene_spec.js +15 -0
- data/spec/lib/entityjs/assets_spec.rb +2 -201
- data/spec/lib/entityjs/commands/build_spec.rb +18 -5
- data/spec/lib/entityjs/commands/eunit_spec.rb +18 -0
- data/spec/lib/entityjs/commands/release_spec.rb +2 -0
- data/spec/lib/entityjs/compile_spec.rb +204 -0
- data/spec/lib/entityjs/dirc_spec.rb +8 -4
- data/spec/lib/entityjs/page_spec.rb +59 -0
- data/spec/support/factories.rb +0 -2
- data/src/core/entity.js +4 -18
- data/src/core/query.js +1 -1
- data/src/core/re.js +6 -6
- data/src/core/system.js +17 -12
- data/src/cycle/tween.js +93 -31
- data/src/display/align.js +11 -6
- data/src/display/circle.js +5 -4
- data/src/display/imgtext.js +33 -22
- data/src/display/screen.js +0 -8
- data/src/display/text.js +37 -4
- data/src/input/keyboard.js +15 -5
- data/src/input/mouse.js +15 -25
- data/src/input/preventdefault.js +11 -0
- data/src/math/body.js +35 -16
- data/src/math/drag.js +2 -2
- data/src/math/force.js +2 -2
- data/src/math/hit.js +15 -6
- data/src/math/hitmap.js +6 -6
- data/src/math/point.js +1 -1
- data/src/math/tile.js +22 -17
- data/src/media/sound.js +1 -1
- data/src/pattern/automap.js +16 -27
- data/src/pattern/flicker.js +9 -5
- data/src/util/random.js +4 -0
- data/src/util/scene.js +2 -6
- data/templates/arrow_keys/scripts/{display → displays}/arrow.js +0 -0
- data/templates/arrow_keys/scripts/{input → inputs}/controls.js +0 -0
- data/templates/arrow_keys/tests/{display → displays}/arrow_test.js +1 -1
- data/templates/arrow_keys/tests/{input → inputs}/controls_test.js +0 -0
- data/templates/arrow_keys/tests/scenes/load_test.js +2 -0
- data/templates/{blank → circle}/config.yml +0 -0
- data/templates/{blank → circle}/readme.txt +0 -0
- data/templates/circle/scripts/init.js +7 -0
- data/templates/circle/scripts/scenes/home.js +62 -0
- data/templates/circle/scripts/scenes/load.js +11 -0
- data/templates/circle/tests/scenes/home_test.js +29 -0
- data/templates/circle/tests/scenes/load_test.js +15 -0
- data/templates/platform/config.yml +2 -1
- data/templates/platform/readme.txt +15 -16
- data/templates/platform/scripts/{display → displays}/bit.js +0 -0
- data/templates/platform/scripts/{display → displays}/hero.js +0 -0
- data/templates/platform/scripts/{display → displays}/tile.js +0 -0
- data/templates/platform/scripts/{display → displays}/tsprite.js +0 -0
- data/templates/platform/{assets → scripts}/levels/level1.tmx +0 -0
- data/templates/platform/scripts/{util → utils}/counter.js +0 -0
- data/templates/platform/scripts/{util → utils}/level.js +0 -0
- data/templates/platform/tests/{display → displays}/bit_test.js +1 -1
- data/templates/platform/tests/displays/hero_test.js +73 -0
- data/templates/platform/tests/{display → displays}/tile_test.js +1 -1
- data/templates/platform/tests/displays/tsprite_test.js +8 -0
- data/templates/platform/tests/items/coin_test.js +10 -10
- data/templates/platform/tests/items/item_test.js +9 -9
- data/templates/platform/tests/items/spring_test.js +3 -3
- data/templates/platform/tests/scenes/load_test.js +2 -1
- data/templates/platform/tests/{util → utils}/counter_test.js +2 -2
- data/templates/platform/tests/{util → utils}/level_test.js +3 -0
- data/templates/pong/config.yml +22 -0
- data/templates/pong/readme.txt +3 -0
- data/templates/pong/scripts/controls/ai.js +30 -0
- data/templates/pong/scripts/controls/arena.js +33 -0
- data/templates/pong/scripts/controls/hitmap.js +54 -0
- data/templates/pong/scripts/controls/player.js +24 -0
- data/templates/pong/scripts/controls/twoarena.js +14 -0
- data/templates/pong/scripts/displays/ball.js +29 -0
- data/templates/pong/scripts/displays/counter.js +22 -0
- data/templates/pong/scripts/displays/paddle.js +22 -0
- data/templates/pong/scripts/init.js +9 -0
- data/templates/pong/scripts/scenes/game.js +61 -0
- data/templates/pong/scripts/scenes/home.js +55 -0
- data/templates/pong/scripts/scenes/over.js +29 -0
- data/templates/pong/tests/controls/ai_test.js +34 -0
- data/templates/pong/tests/controls/arena_test.js +20 -0
- data/templates/pong/tests/controls/hitmap_test.js +89 -0
- data/templates/pong/tests/controls/player_test.js +25 -0
- data/templates/pong/tests/controls/twoarena_test.js +7 -0
- data/templates/pong/tests/displays/ball_test.js +10 -0
- data/templates/pong/tests/displays/counter_test.js +13 -0
- data/templates/pong/tests/displays/paddle_test.js +17 -0
- data/templates/pong/tests/scenes/game_test.js +16 -0
- data/templates/pong/tests/scenes/home_test.js +30 -0
- data/templates/pong/tests/scenes/over_test.js +16 -0
- data/templates/tiltmaze/config.yml +25 -0
- data/templates/tiltmaze/readme.txt +79 -0
- data/templates/tiltmaze/scripts/displays/ball.js +78 -0
- data/templates/tiltmaze/scripts/displays/target.js +13 -0
- data/templates/tiltmaze/scripts/displays/tile.js +2 -0
- data/templates/tiltmaze/scripts/init.js +7 -0
- data/templates/tiltmaze/scripts/levels/level1.json +14 -0
- data/templates/tiltmaze/scripts/levels/level2.json +14 -0
- data/templates/tiltmaze/scripts/levels/level3.json +14 -0
- data/templates/tiltmaze/scripts/levels/level4.json +15 -0
- data/templates/tiltmaze/scripts/levels/level5.json +18 -0
- data/templates/tiltmaze/scripts/scenes/game.js +56 -0
- data/templates/tiltmaze/scripts/scenes/home.js +24 -0
- data/templates/tiltmaze/scripts/structs/level.js +82 -0
- data/templates/tiltmaze/scripts/tiles/walltile.js +147 -0
- data/templates/tiltmaze/tests/displays/ball_test.js +67 -0
- data/templates/tiltmaze/tests/displays/target_test.js +8 -0
- data/templates/tiltmaze/tests/factories.js +38 -0
- data/templates/tiltmaze/tests/scenes/game_test.js +59 -0
- data/templates/tiltmaze/tests/scenes/home_test.js +7 -0
- data/templates/tiltmaze/tests/structs/level_test.js +44 -0
- data/templates/tiltmaze/tests/tiles/walltile_test.js +36 -0
- metadata +106 -33
- data/templates/platform/tests/display/hero_test.js +0 -73
- data/templates/platform/tests/display/tsprite_test.js +0 -8
@@ -0,0 +1,20 @@
|
|
1
|
+
module('controls/arena', lazy('arena'));
|
2
|
+
|
3
|
+
test('start round', function(){
|
4
|
+
|
5
|
+
arena.startRound();
|
6
|
+
|
7
|
+
is(arena.ball);
|
8
|
+
|
9
|
+
ok(re('ball').length == 1);
|
10
|
+
|
11
|
+
|
12
|
+
});
|
13
|
+
|
14
|
+
test('stop round', function(){
|
15
|
+
|
16
|
+
arena.stopRound();
|
17
|
+
|
18
|
+
expect(0);
|
19
|
+
|
20
|
+
});
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
The hitmap controls the balls boundaires, so i'll write some extra tests to make sure it works.
|
3
|
+
*/
|
4
|
+
module('controls/hitmap', {
|
5
|
+
setup:function(){
|
6
|
+
hitmap = f('hitmap');
|
7
|
+
ball = f('ball');
|
8
|
+
},
|
9
|
+
teardown:function(){
|
10
|
+
hitmap.dispose();
|
11
|
+
ball.dispose();
|
12
|
+
}
|
13
|
+
});
|
14
|
+
|
15
|
+
test('ball hitting the left side should trigger event', function(){
|
16
|
+
|
17
|
+
ball.posX = -1 + ball.hsizeX;
|
18
|
+
|
19
|
+
expectTrigger(hitmap, 'score:left');
|
20
|
+
|
21
|
+
hitmap.checkHit(ball);
|
22
|
+
|
23
|
+
});
|
24
|
+
|
25
|
+
test('ball hitting the right side should trigger event', function(){
|
26
|
+
|
27
|
+
ball.posX = re.sys.sizeX - ball.hsizeX + 1;
|
28
|
+
|
29
|
+
expectTrigger(hitmap, 'score:right');
|
30
|
+
|
31
|
+
hitmap.checkHit(ball);
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
test('ball should hit top', function(){
|
36
|
+
|
37
|
+
ball.posY = -1 + ball.hsizeY;
|
38
|
+
|
39
|
+
var res = hitmap.checkHit(ball);
|
40
|
+
|
41
|
+
eq(res.hitY, 1);
|
42
|
+
eq(res.posY, ball.hsizeY);
|
43
|
+
|
44
|
+
});
|
45
|
+
|
46
|
+
test('ball should hit bottom', function(){
|
47
|
+
|
48
|
+
ball.posY = re.sys.sizeY - ball.hsizeY + 1;
|
49
|
+
|
50
|
+
var res = hitmap.checkHit(ball);
|
51
|
+
|
52
|
+
eq(res.hitY, 1);
|
53
|
+
eq(res.posY, re.sys.sizeY - ball.hsizeY);
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
test('ball should hit right of paddle', function(){
|
58
|
+
|
59
|
+
var paddle = re.e('paddle')
|
60
|
+
.attr({
|
61
|
+
posX:100,
|
62
|
+
posY:100
|
63
|
+
});
|
64
|
+
|
65
|
+
ball.posX = paddle.posX + paddle.hsizeX + ball.hsizeX;
|
66
|
+
|
67
|
+
var res = hitmap.checkHit(ball);
|
68
|
+
|
69
|
+
ok(res.hitX);
|
70
|
+
eq(res.posX, ball.posX+1);
|
71
|
+
|
72
|
+
})
|
73
|
+
|
74
|
+
test('ball should hit left of paddle', function(){
|
75
|
+
|
76
|
+
var paddle = re.e('paddle')
|
77
|
+
.attr({
|
78
|
+
posX:100,
|
79
|
+
posY:100
|
80
|
+
});
|
81
|
+
|
82
|
+
ball.posX = paddle.posX - ball.hsizeX - paddle.hsizeX;
|
83
|
+
|
84
|
+
var res = hitmap.checkHit(ball);
|
85
|
+
|
86
|
+
ok(res.hitX);
|
87
|
+
eq(res.posX, ball.posX-1);
|
88
|
+
|
89
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module('controls/player', lazy('player'));
|
2
|
+
|
3
|
+
test('paddle moves down on w press', function(){
|
4
|
+
|
5
|
+
player.posY = 30;
|
6
|
+
|
7
|
+
expectValueDown(player, 'posY');
|
8
|
+
|
9
|
+
keypress('w', function(){
|
10
|
+
player.update();
|
11
|
+
});
|
12
|
+
|
13
|
+
});
|
14
|
+
|
15
|
+
test('paddle moves up on s press', function(){
|
16
|
+
|
17
|
+
player.posY = 10;
|
18
|
+
|
19
|
+
expectValueUp(player, 'posY');
|
20
|
+
|
21
|
+
keypress('s', function(){
|
22
|
+
player.update();
|
23
|
+
});
|
24
|
+
|
25
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module('displays/paddle', lazy('paddle'));
|
2
|
+
|
3
|
+
test('stay within bounds', function(){
|
4
|
+
|
5
|
+
paddle.posY = -10;
|
6
|
+
|
7
|
+
paddle.checkBounds();
|
8
|
+
|
9
|
+
ok(paddle.posY >= 0);
|
10
|
+
|
11
|
+
paddle.posY = re.sys.sizeY + 10;
|
12
|
+
|
13
|
+
paddle.checkBounds();
|
14
|
+
|
15
|
+
ok(paddle.posY <= re.sys.sizeY)
|
16
|
+
|
17
|
+
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module('scenes/home', {
|
2
|
+
setup:function(){
|
3
|
+
re.scene('home').enter();
|
4
|
+
},
|
5
|
+
teardown:function(){
|
6
|
+
re.scene('home').exit();
|
7
|
+
}
|
8
|
+
});
|
9
|
+
|
10
|
+
test('create home screen', function(){
|
11
|
+
|
12
|
+
is(re('text')[0]);
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
test('z should go to single player', function(){
|
17
|
+
|
18
|
+
expectCall(re.scene('game'), 'enter', [false]);
|
19
|
+
|
20
|
+
keyup('z');
|
21
|
+
|
22
|
+
});
|
23
|
+
|
24
|
+
test('x should go to two player', function(){
|
25
|
+
|
26
|
+
expectCall(re.scene('game'), 'enter', [true]);
|
27
|
+
|
28
|
+
keyup('x');
|
29
|
+
|
30
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module('scenes/over');
|
2
|
+
|
3
|
+
test('enter over scene', function(){
|
4
|
+
|
5
|
+
var message = 'You lost!';
|
6
|
+
|
7
|
+
re.scene('over').enter(message);
|
8
|
+
|
9
|
+
eq(re('text')[0].text(), message);
|
10
|
+
|
11
|
+
expectCall(re.scene('home'), 'enter');
|
12
|
+
|
13
|
+
//back to home
|
14
|
+
keyup('z');
|
15
|
+
|
16
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Configure your game settings
|
2
|
+
|
3
|
+
width: 180
|
4
|
+
height: 180
|
5
|
+
canvas-id: game-canvas
|
6
|
+
|
7
|
+
canvas-border: false
|
8
|
+
|
9
|
+
#files to ignore in /scripts
|
10
|
+
scripts-ignore:
|
11
|
+
|
12
|
+
#specify files to be loaded first in /scripts
|
13
|
+
order:
|
14
|
+
/tile.js$
|
15
|
+
|
16
|
+
#components to ignore in the entityjs source
|
17
|
+
#reduce file size by ignoring unused components
|
18
|
+
entity-ignore:
|
19
|
+
socket
|
20
|
+
wait
|
21
|
+
group
|
22
|
+
|
23
|
+
#ignore tests in /tests
|
24
|
+
tests-ignore:
|
25
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
------------- EntityJS Gem ----------------------
|
2
|
+
|
3
|
+
The EntityJS Gem lets you quickly create HTML5 javascript games.
|
4
|
+
|
5
|
+
# Directory Structure
|
6
|
+
|
7
|
+
## /assets
|
8
|
+
Contains all sounds, images and data files. Place all sounds in the sounds directory
|
9
|
+
and all the images in the images directory. These directories will be looked at
|
10
|
+
and an asset array will be created for easy asset loading (see scripts/scenes/load.js)
|
11
|
+
|
12
|
+
Creating any other directory or placing files in the levels directory will be seen
|
13
|
+
as data files and will be read and automatically put in js files.
|
14
|
+
|
15
|
+
For example, if I have a directory like /assets/animations/monster.json.
|
16
|
+
|
17
|
+
The file will automatically be read upon calling 'entityjs refresh' and will be turned into this:
|
18
|
+
|
19
|
+
re.e('monster.json animation')
|
20
|
+
.attr(**Animation JSON here**);
|
21
|
+
|
22
|
+
Which means you can edit files in different programs and not worry about copying and pasting
|
23
|
+
the contents. Just run entityjs refresh.
|
24
|
+
|
25
|
+
At the moment JSON, XML and TMX is supported but in the future, YAML, and CSV will be supported.
|
26
|
+
TMX is a special XML format for a tile map editor called tiled.
|
27
|
+
|
28
|
+
## /builds
|
29
|
+
|
30
|
+
Contains assets and minified code for the game.
|
31
|
+
|
32
|
+
## /scripts
|
33
|
+
|
34
|
+
Contains javascripts for the game.
|
35
|
+
|
36
|
+
## /tests
|
37
|
+
|
38
|
+
Contains tests for the game. It is good practice to keep this structured exactly the same as the scripts
|
39
|
+
directory.
|
40
|
+
|
41
|
+
## config.yml
|
42
|
+
|
43
|
+
A configuration file in yaml. This can be edited in any text editor.
|
44
|
+
|
45
|
+
## readme.txt
|
46
|
+
|
47
|
+
Good practice to make one for every game to help other people.
|
48
|
+
|
49
|
+
# Commands
|
50
|
+
|
51
|
+
## create a new entityjs game
|
52
|
+
entityjs new [project_name]
|
53
|
+
|
54
|
+
- example
|
55
|
+
entityjs new alien_shooter
|
56
|
+
|
57
|
+
- create game with arrow_keys template
|
58
|
+
entityjs new alien_shooter alien arrow_keys
|
59
|
+
|
60
|
+
## create a new component
|
61
|
+
entityjs comp [component_name]
|
62
|
+
|
63
|
+
- example
|
64
|
+
entityjs comp hero
|
65
|
+
|
66
|
+
## build game
|
67
|
+
entityjs build
|
68
|
+
|
69
|
+
Exports game in builds directory
|
70
|
+
|
71
|
+
## build game with custom name
|
72
|
+
entityjs build release1
|
73
|
+
|
74
|
+
## Run server
|
75
|
+
entityjs server
|
76
|
+
or
|
77
|
+
entityjs s
|
78
|
+
|
79
|
+
Navigate to localhost:2345 to play the game.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
re.c('ball')
|
2
|
+
.requires('tile draw update')
|
3
|
+
.defines({
|
4
|
+
color:'#ff0000',
|
5
|
+
speed:6,
|
6
|
+
moving:false,
|
7
|
+
pad:5,
|
8
|
+
|
9
|
+
draw:function(c){
|
10
|
+
c.fillStyle = this.color;
|
11
|
+
|
12
|
+
c.beginPath();
|
13
|
+
var r = 10;
|
14
|
+
|
15
|
+
c.arc(r + 5, r + 5, r, 0, Math.PI*2, true);
|
16
|
+
|
17
|
+
c.closePath();
|
18
|
+
|
19
|
+
c.fill();
|
20
|
+
},
|
21
|
+
|
22
|
+
move:function(x, y){
|
23
|
+
|
24
|
+
var tx = this.tileX();
|
25
|
+
var ty = this.tileY();
|
26
|
+
|
27
|
+
var tile = this.level.automap(tx, ty);
|
28
|
+
var tileAfter = this.level.automap(tx+x, ty+y);
|
29
|
+
|
30
|
+
if(tileAfter && !tile.checkWallInside(x, y) && !tileAfter.checkWall(x, y)){
|
31
|
+
|
32
|
+
if(y){
|
33
|
+
this.posY += this.speed * y;
|
34
|
+
}
|
35
|
+
if(x){
|
36
|
+
this.posX += this.speed * x;
|
37
|
+
}
|
38
|
+
|
39
|
+
} else {
|
40
|
+
this.tile(tx, ty);
|
41
|
+
this.moving = false;
|
42
|
+
this.off('update');
|
43
|
+
this.on('update', this.update);
|
44
|
+
this.trigger('move:finish');
|
45
|
+
}
|
46
|
+
|
47
|
+
this.trigger('move:update');
|
48
|
+
},
|
49
|
+
|
50
|
+
keydown:function(x, y){
|
51
|
+
if(this.moving) return;
|
52
|
+
this.moving = true;
|
53
|
+
this.on('update', function(){
|
54
|
+
this.move(x, y);
|
55
|
+
});
|
56
|
+
},
|
57
|
+
|
58
|
+
update:function(){
|
59
|
+
|
60
|
+
if(re.pressed('a', 'left')){
|
61
|
+
this.keydown(-1, 0);
|
62
|
+
} else if(re.pressed('d', 'right')){
|
63
|
+
this.keydown(1, 0);
|
64
|
+
}
|
65
|
+
|
66
|
+
if(re.pressed('s', 'down')){
|
67
|
+
this.keydown(0, 1);
|
68
|
+
} else if(re.pressed('w', 'up')){
|
69
|
+
this.keydown(0, -1);
|
70
|
+
}
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
})
|
75
|
+
.init(function(){
|
76
|
+
|
77
|
+
this.on('update', this.update);
|
78
|
+
});
|
@@ -0,0 +1,56 @@
|
|
1
|
+
re.scene('game')
|
2
|
+
.enter(function(levelNum){
|
3
|
+
|
4
|
+
//prevent default browser actions
|
5
|
+
re.preventDefault('left right up down');
|
6
|
+
|
7
|
+
this.setLevel(levelNum);
|
8
|
+
this.currentLevel.setup();
|
9
|
+
|
10
|
+
var self = this;
|
11
|
+
|
12
|
+
//set keyboard shortcuts
|
13
|
+
re.e('keyboard')
|
14
|
+
.on('keyup:q', function(){
|
15
|
+
self.quit();
|
16
|
+
})
|
17
|
+
.on('keyup:r', function(){
|
18
|
+
self.restart();
|
19
|
+
});
|
20
|
+
|
21
|
+
})
|
22
|
+
.attr({
|
23
|
+
|
24
|
+
setLevel:function(num){
|
25
|
+
|
26
|
+
this.currentLevel = re.level.get(num);
|
27
|
+
this.num = num;
|
28
|
+
|
29
|
+
if(!re.is(this.currentLevel)){
|
30
|
+
this.num = 1;
|
31
|
+
this.currentLevel = re.level.get(1);
|
32
|
+
}
|
33
|
+
|
34
|
+
},
|
35
|
+
|
36
|
+
advance:function(){
|
37
|
+
this.num++;
|
38
|
+
|
39
|
+
this.enter(this.num);
|
40
|
+
},
|
41
|
+
|
42
|
+
restart:function(){
|
43
|
+
this.enter(this.num);
|
44
|
+
},
|
45
|
+
|
46
|
+
quit:function(){
|
47
|
+
re.scene('home').enter();
|
48
|
+
}
|
49
|
+
|
50
|
+
})
|
51
|
+
.exit(function(){
|
52
|
+
|
53
|
+
this.currentLevel.teardown();
|
54
|
+
re('keyboard').dispose();
|
55
|
+
|
56
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
re.scene('home')
|
2
|
+
.enter(function(){
|
3
|
+
|
4
|
+
//add help text
|
5
|
+
re.e('text align')
|
6
|
+
.attr({
|
7
|
+
font:'bold 30px Verdina',
|
8
|
+
text:'Tiltmaze'
|
9
|
+
})
|
10
|
+
.align(0, -60);
|
11
|
+
|
12
|
+
re.e('text align keyboard')
|
13
|
+
.text('Press any key to begin\nQ - Quit\nR - Restart')
|
14
|
+
.align()
|
15
|
+
.on('keyup', function(){
|
16
|
+
re.scene('game').enter(1);
|
17
|
+
});
|
18
|
+
|
19
|
+
})
|
20
|
+
.exit(function(){
|
21
|
+
|
22
|
+
re('text').dispose();
|
23
|
+
|
24
|
+
});
|