entityjs 0.3.2 → 0.4.0
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 +1 -1
- data/lib/entityjs/config.rb +4 -4
- data/lib/entityjs/dirc.rb +2 -2
- data/lib/entityjs/page.rb +7 -1
- data/lib/entityjs/version.rb +1 -1
- data/public/qunit/qunit.entity.js +27 -12
- data/spec/javascripts/src/core/comp_spec.js +11 -0
- data/spec/javascripts/src/core/entity_spec.js +88 -5
- data/spec/javascripts/src/core/query_spec.js +196 -15
- data/spec/javascripts/src/cycle/drawlist_spec.js +36 -0
- data/spec/javascripts/src/cycle/tween_spec.js +1 -1
- data/spec/javascripts/src/cycle/wait_spec.js +31 -0
- data/spec/javascripts/src/{cycle → display}/draw_spec.js +25 -9
- data/spec/javascripts/src/display/sprite_spec.js +18 -0
- data/spec/javascripts/src/display/text_spec.js +8 -0
- data/spec/javascripts/src/input/mouse_spec.js +24 -36
- data/spec/javascripts/src/math/bisect_spec.js +4 -4
- data/spec/javascripts/src/math/distance_spec.js +11 -0
- data/spec/javascripts/src/math/iso_spec.js +131 -0
- data/spec/javascripts/src/math/point_spec.js +3 -3
- data/spec/javascripts/src/{util → math}/random_spec.js +0 -0
- data/spec/javascripts/src/math/range_spec.js +9 -0
- data/spec/javascripts/src/math/tile_spec.js +22 -7
- data/spec/javascripts/src/pattern/automap_spec.js +2 -2
- data/spec/javascripts/src/pattern/flicker_spec.js +34 -22
- data/spec/javascripts/src/pattern/pathfind_spec.js +55 -0
- data/src/core/comp.js +16 -16
- data/src/core/entity.js +52 -51
- data/src/core/load.js +5 -5
- data/src/core/query.js +214 -74
- data/src/core/system.js +16 -6
- data/src/cycle/drawlist.js +79 -0
- data/src/cycle/tween.js +7 -20
- data/src/cycle/wait.js +10 -19
- data/src/{cycle → display}/draw.js +24 -34
- data/src/display/image.js +1 -1
- data/src/display/screen.js +3 -3
- data/src/display/sprite.js +3 -3
- data/src/display/text.js +3 -1
- data/src/input/mouse.js +35 -12
- data/src/math/bisect.js +11 -10
- data/src/math/distance.js +7 -0
- data/src/math/iso.js +147 -0
- data/src/math/point.js +1 -5
- data/src/math/random.js +21 -0
- data/src/math/range.js +14 -0
- data/src/math/tile.js +40 -27
- data/src/pattern/automap.js +12 -11
- data/src/pattern/flicker.js +87 -135
- data/src/pattern/pathfind.js +168 -0
- data/src/pattern/timestep.js +4 -1
- data/src/util/polyfill.js +1 -1
- data/templates/isometric/assets/images/isotiles.png +0 -0
- data/templates/isometric/config.yml +22 -0
- data/templates/isometric/readme.txt +79 -0
- data/templates/isometric/scripts/displays/cursor.js +34 -0
- data/templates/isometric/scripts/displays/isoimage.js +32 -0
- data/templates/isometric/scripts/init.js +7 -0
- data/templates/isometric/scripts/levels/level.js +55 -0
- data/templates/isometric/scripts/levels/level1.js +11 -0
- data/templates/isometric/scripts/scenes/home.js +10 -0
- data/templates/isometric/scripts/scenes/load.js +11 -0
- data/templates/isometric/tests/scenes/load_test.js +15 -0
- metadata +42 -21
- data/src/net/socket.js +0 -52
- data/src/util/random.js +0 -24
@@ -0,0 +1,36 @@
|
|
1
|
+
describe('cycle/drawlist', function(){
|
2
|
+
|
3
|
+
var drawlist;
|
4
|
+
|
5
|
+
beforeEach(function(){
|
6
|
+
|
7
|
+
drawlist = re.drawlist('test');
|
8
|
+
|
9
|
+
});
|
10
|
+
|
11
|
+
it('add', function(){
|
12
|
+
var blah = re.e('circle');
|
13
|
+
drawlist.add(blah);
|
14
|
+
|
15
|
+
ok(drawlist.list.include(blah))
|
16
|
+
})
|
17
|
+
|
18
|
+
it('remove', function(){
|
19
|
+
|
20
|
+
var blah = re.e('circle');
|
21
|
+
drawlist.add(blah);
|
22
|
+
drawlist.remove(blah);
|
23
|
+
not(drawlist.list.include(blah))
|
24
|
+
})
|
25
|
+
|
26
|
+
it('drawlist', function(){
|
27
|
+
//drawlist.drawlist();
|
28
|
+
//smoke test
|
29
|
+
})
|
30
|
+
|
31
|
+
it('sort', function(){
|
32
|
+
drawlist.sort();
|
33
|
+
//an other smoke test
|
34
|
+
})
|
35
|
+
|
36
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe('cycle/wait', function(){
|
2
|
+
|
3
|
+
var wait;
|
4
|
+
|
5
|
+
beforeEach(function(){
|
6
|
+
wait = re.e('wait');
|
7
|
+
});
|
8
|
+
|
9
|
+
it('should wait', function(){
|
10
|
+
|
11
|
+
var called= false;
|
12
|
+
|
13
|
+
runs(function(){
|
14
|
+
|
15
|
+
is(wait.wait(function(){
|
16
|
+
called = true;
|
17
|
+
console.log('ran')
|
18
|
+
}, 100));
|
19
|
+
console.log('hey')
|
20
|
+
});
|
21
|
+
|
22
|
+
waits(101);
|
23
|
+
|
24
|
+
runs(function(){
|
25
|
+
ok(called)
|
26
|
+
console.log('last')
|
27
|
+
});
|
28
|
+
|
29
|
+
});
|
30
|
+
|
31
|
+
});
|
@@ -1,16 +1,32 @@
|
|
1
1
|
describe('draw', function(){
|
2
2
|
|
3
|
-
var d;
|
3
|
+
var d, list;
|
4
4
|
|
5
5
|
beforeEach(function(){
|
6
|
+
list = re.drawlist().list;
|
7
|
+
|
6
8
|
re.c('shape')
|
7
|
-
.requires('draw')
|
9
|
+
.requires('draw')
|
10
|
+
.defines('draw', function(){
|
8
11
|
})
|
9
12
|
|
10
13
|
d = re.e('shape')
|
11
14
|
})
|
12
15
|
|
13
16
|
|
17
|
+
it('should sort rect first', function(){
|
18
|
+
|
19
|
+
var rect = re.e('shape');
|
20
|
+
rect.depth = function(){
|
21
|
+
return -1000;
|
22
|
+
};
|
23
|
+
|
24
|
+
re.drawlist().sort();
|
25
|
+
|
26
|
+
eq(list[0], rect);
|
27
|
+
|
28
|
+
})
|
29
|
+
|
14
30
|
it('create', function(){
|
15
31
|
var called = false
|
16
32
|
re.sys.start();
|
@@ -34,7 +50,7 @@ describe('draw', function(){
|
|
34
50
|
is(re.e('shape ddd').drawFirst())
|
35
51
|
|
36
52
|
var l = 0
|
37
|
-
ok(
|
53
|
+
ok(list[l].has('ddd'))
|
38
54
|
})
|
39
55
|
|
40
56
|
it('drawLast', function(){
|
@@ -44,8 +60,8 @@ describe('draw', function(){
|
|
44
60
|
|
45
61
|
is(k.drawLast())
|
46
62
|
|
47
|
-
var l =
|
48
|
-
ok(
|
63
|
+
var l = list.length-1
|
64
|
+
ok(list[l].has('db77'))
|
49
65
|
|
50
66
|
})
|
51
67
|
|
@@ -57,8 +73,8 @@ describe('draw', function(){
|
|
57
73
|
is(k.drawBefore(b))
|
58
74
|
|
59
75
|
|
60
|
-
var l =
|
61
|
-
ok(
|
76
|
+
var l = list.indexOf(b)-1
|
77
|
+
ok(list[l].has('db777'))
|
62
78
|
|
63
79
|
})
|
64
80
|
|
@@ -68,8 +84,8 @@ describe('draw', function(){
|
|
68
84
|
var b = re.e('shape b')
|
69
85
|
|
70
86
|
is(k.drawAfter(b))
|
71
|
-
var l =
|
72
|
-
ok(
|
87
|
+
var l = list.indexOf(b)+1
|
88
|
+
ok(list[l].has('db777y'))
|
73
89
|
|
74
90
|
})
|
75
91
|
|
@@ -20,6 +20,24 @@ describe('sprite', function(){
|
|
20
20
|
eq(e.frame(), 1)
|
21
21
|
});
|
22
22
|
|
23
|
+
it('should display second row', function(){
|
24
|
+
|
25
|
+
e.bisect = 2001;
|
26
|
+
e.sizeY = 80;
|
27
|
+
e.sizeX = 87;
|
28
|
+
|
29
|
+
e.frame(22);
|
30
|
+
|
31
|
+
eq(e.frameX, 22)
|
32
|
+
eq(e.frameY, 0)
|
33
|
+
|
34
|
+
//tricky part
|
35
|
+
e.frame(23);
|
36
|
+
eq(e.frameX, 0);
|
37
|
+
eq(e.frameY, 1);
|
38
|
+
|
39
|
+
})
|
40
|
+
|
23
41
|
it('draw', function(){
|
24
42
|
is(e.draw(re.sys.context))
|
25
43
|
|
@@ -23,6 +23,14 @@ describe('text', function(){
|
|
23
23
|
not(f.visible())
|
24
24
|
})
|
25
25
|
|
26
|
+
it('should join strings', function(){
|
27
|
+
|
28
|
+
f.text('blah',10,"nice");
|
29
|
+
|
30
|
+
eq(f.text(), 'blah 10 nice');
|
31
|
+
|
32
|
+
});
|
33
|
+
|
26
34
|
it('should draw', function(){
|
27
35
|
f.text('m\nlinesdfsdfsdfsdsdfsdfsdfsdfsdfsfsf')
|
28
36
|
is(f.draw(re.sys.context))
|
@@ -10,13 +10,11 @@ describe('mouse', function(){
|
|
10
10
|
var type = 'mousedown'
|
11
11
|
var called, called2;
|
12
12
|
|
13
|
-
e.on(type, function(
|
13
|
+
e.on(type, function(x,y, e){
|
14
14
|
called = true
|
15
|
-
is(
|
16
|
-
is(
|
17
|
-
is(
|
18
|
-
is(m.posX)
|
19
|
-
is(m.posY)
|
15
|
+
is(x)
|
16
|
+
is(y)
|
17
|
+
is(e)
|
20
18
|
});
|
21
19
|
|
22
20
|
e.on(type+':middle', function(m, e){
|
@@ -34,13 +32,11 @@ describe('mouse', function(){
|
|
34
32
|
var type = 'mouseup'
|
35
33
|
var called, called2;
|
36
34
|
|
37
|
-
e.on(type, function(
|
35
|
+
e.on(type, function(x,y, e){
|
38
36
|
called = true
|
39
|
-
is(
|
40
|
-
is(
|
41
|
-
is(
|
42
|
-
is(m.posX)
|
43
|
-
is(m.posY)
|
37
|
+
is(x)
|
38
|
+
is(y)
|
39
|
+
is(e)
|
44
40
|
});
|
45
41
|
|
46
42
|
e.on(type+':middle', function(m, e){
|
@@ -60,13 +56,11 @@ describe('mouse', function(){
|
|
60
56
|
var type = 'mousemove'
|
61
57
|
var called;
|
62
58
|
|
63
|
-
e.on(type, function(
|
59
|
+
e.on(type, function(x,y, e){
|
64
60
|
called = true
|
65
|
-
is(
|
66
|
-
is(
|
67
|
-
is(
|
68
|
-
is(m.posX)
|
69
|
-
is(m.posY)
|
61
|
+
is(x)
|
62
|
+
is(y)
|
63
|
+
is(e)
|
70
64
|
});
|
71
65
|
|
72
66
|
re.c('mouse').event({type:type, offsetX:0, offsetY:0})
|
@@ -79,13 +73,11 @@ describe('mouse', function(){
|
|
79
73
|
var type = 'click'
|
80
74
|
var called;
|
81
75
|
|
82
|
-
e.on(type, function(
|
76
|
+
e.on(type, function(x,y, e){
|
83
77
|
called = true
|
84
|
-
is(
|
85
|
-
is(
|
86
|
-
is(
|
87
|
-
is(m.posX)
|
88
|
-
is(m.posY)
|
78
|
+
is(x)
|
79
|
+
is(y)
|
80
|
+
is(e)
|
89
81
|
});
|
90
82
|
|
91
83
|
re.c('mouse').event({type:type, offsetX:0, offsetY:0})
|
@@ -98,13 +90,11 @@ describe('mouse', function(){
|
|
98
90
|
var type = 'dblclick'
|
99
91
|
var called;
|
100
92
|
|
101
|
-
e.on(type, function(
|
93
|
+
e.on(type, function(x,y, e){
|
102
94
|
called = true
|
103
|
-
is(
|
104
|
-
is(
|
105
|
-
is(
|
106
|
-
is(m.posX)
|
107
|
-
is(m.posY)
|
95
|
+
is(x)
|
96
|
+
is(y)
|
97
|
+
is(e)
|
108
98
|
});
|
109
99
|
|
110
100
|
re.c('mouse').event({type:type, offsetX:0, offsetY:0})
|
@@ -117,13 +107,11 @@ describe('mouse', function(){
|
|
117
107
|
var type = 'contextmenu'
|
118
108
|
var called;
|
119
109
|
|
120
|
-
e.on(type, function(
|
110
|
+
e.on(type, function(x,y, e){
|
121
111
|
called = true
|
122
|
-
is(
|
123
|
-
is(
|
124
|
-
is(
|
125
|
-
is(m.posX)
|
126
|
-
is(m.posY)
|
112
|
+
is(x)
|
113
|
+
is(y)
|
114
|
+
is(e)
|
127
115
|
});
|
128
116
|
|
129
117
|
re.c('mouse').event({type:type, offsetX:0, offsetY:0})
|
@@ -10,21 +10,21 @@ describe('bisect', function(){
|
|
10
10
|
});
|
11
11
|
|
12
12
|
it('static biToX', function(){
|
13
|
-
eq(re.bisect.
|
13
|
+
eq(re.bisect.toX(1, 160, 60), 60)
|
14
14
|
});
|
15
15
|
|
16
16
|
it('static biToY', function(){
|
17
|
-
eq(re.bisect.
|
17
|
+
eq(re.bisect.toY(1, 160, 60), 0)
|
18
18
|
|
19
19
|
});
|
20
20
|
|
21
21
|
it('static biToTileX', function(){
|
22
|
-
eq(re.bisect.
|
22
|
+
eq(re.bisect.toTileX(1, 160, 60), 1)
|
23
23
|
|
24
24
|
});
|
25
25
|
|
26
26
|
it('static biToTileY', function(){
|
27
|
-
eq(re.bisect.
|
27
|
+
eq(re.bisect.toTileY(1, 160, 60), 0)
|
28
28
|
|
29
29
|
});
|
30
30
|
|
@@ -0,0 +1,131 @@
|
|
1
|
+
describe('math/iso', function(){
|
2
|
+
|
3
|
+
var e;
|
4
|
+
|
5
|
+
beforeEach(function(){
|
6
|
+
re.iso.sizeX = 30;
|
7
|
+
re.iso.sizeY = 30;
|
8
|
+
re.iso.sizeZ = 30;
|
9
|
+
|
10
|
+
e = re.e('iso');
|
11
|
+
|
12
|
+
});
|
13
|
+
|
14
|
+
it('toPos', function(){
|
15
|
+
var e = re.iso.toPos(125, 82)
|
16
|
+
|
17
|
+
eq(e.posX, 90)
|
18
|
+
e = re.iso.toPos(125, 82)
|
19
|
+
eq(e.posY, 75)
|
20
|
+
})
|
21
|
+
|
22
|
+
it('toPosX', function(){
|
23
|
+
|
24
|
+
eq(re.iso.toIsoX(125, 82), 4)
|
25
|
+
eq(re.iso.toIsoY(125, 82), 1)
|
26
|
+
eq(re.iso.toPosX(125, 82), 90);
|
27
|
+
|
28
|
+
})
|
29
|
+
|
30
|
+
it('toPosY', function(){
|
31
|
+
eq(re.iso.toIsoX(65, 96), 3)
|
32
|
+
eq(re.iso.toIsoY(65, 96), 2)
|
33
|
+
|
34
|
+
eq(re.iso.toPosY(65, 96), 75);
|
35
|
+
|
36
|
+
})
|
37
|
+
|
38
|
+
it('toIso', function(){
|
39
|
+
var e = re.iso.toIso(-9, 90)
|
40
|
+
|
41
|
+
eq(e.isoX, 2)
|
42
|
+
|
43
|
+
e = re.iso.toIso(-5, 30)
|
44
|
+
|
45
|
+
eq(e.isoY, 1)
|
46
|
+
})
|
47
|
+
|
48
|
+
it('toIsoX', function(){
|
49
|
+
|
50
|
+
eq(re.iso.toIsoX(-9, 90), 2);
|
51
|
+
})
|
52
|
+
|
53
|
+
it('toIsoY', function(){
|
54
|
+
|
55
|
+
eq(re.iso.toIsoY(-5, 30), 1);
|
56
|
+
})
|
57
|
+
|
58
|
+
it('should add correctly', function(){
|
59
|
+
|
60
|
+
var oldX = e.isoX();
|
61
|
+
e.isoY(4);
|
62
|
+
|
63
|
+
for(var i=0; i<8; i++){
|
64
|
+
e.isoY(e.isoY() + 0.25)
|
65
|
+
}
|
66
|
+
|
67
|
+
eq(e.isoY(), 6);
|
68
|
+
eq(e.isoX(), oldX);
|
69
|
+
|
70
|
+
});
|
71
|
+
|
72
|
+
it('iso normal args', function(){
|
73
|
+
|
74
|
+
eq(e.iso(2, 2, 2), e);
|
75
|
+
|
76
|
+
eq(e.isoX(), 2)
|
77
|
+
eq(e.isoY(), 2)
|
78
|
+
eq(e.isoZ(), 2)
|
79
|
+
|
80
|
+
})
|
81
|
+
|
82
|
+
it('iso obj args', function(){
|
83
|
+
|
84
|
+
eq(e.iso({x:2, y:2, z:2}), e);
|
85
|
+
|
86
|
+
eq(e.isoX(), 2)
|
87
|
+
eq(e.isoY(), 2)
|
88
|
+
eq(e.isoZ(), 2)
|
89
|
+
|
90
|
+
})
|
91
|
+
|
92
|
+
it('iso copy other iso position', function(){
|
93
|
+
|
94
|
+
var iso = re.e('iso');
|
95
|
+
iso.iso(2, 2, 2);
|
96
|
+
|
97
|
+
eq(e.iso(iso), e);
|
98
|
+
|
99
|
+
eq(e.isoX(), 2)
|
100
|
+
eq(e.isoY(), 2)
|
101
|
+
eq(e.isoZ(), 2)
|
102
|
+
|
103
|
+
})
|
104
|
+
|
105
|
+
it('isoX', function(){
|
106
|
+
eq(e.isoX(4), e);
|
107
|
+
|
108
|
+
eq(e.isoX(), 4);
|
109
|
+
|
110
|
+
eq(e.posX, 120)
|
111
|
+
eq(e.posY, 60)
|
112
|
+
|
113
|
+
})
|
114
|
+
|
115
|
+
it('isoY', function(){
|
116
|
+
eq(e.isoY(1), e);
|
117
|
+
|
118
|
+
eq(e.isoY(), 1);
|
119
|
+
|
120
|
+
eq(e.posX, -30)
|
121
|
+
eq(e.posY, 15)
|
122
|
+
})
|
123
|
+
|
124
|
+
it('isoZ', function(){
|
125
|
+
|
126
|
+
eq(e.isoZ(1), e);
|
127
|
+
|
128
|
+
eq(e.isoZ(), 1);
|
129
|
+
})
|
130
|
+
|
131
|
+
});
|