-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectExplosion.class.js
70 lines (56 loc) · 1.59 KB
/
ObjectExplosion.class.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { ObjectStatic } from './ObjectStatic.class.js'
import { EngineStateMachine } from './EngineStateMachine.class.js';
import { floor } from './library.inc.js';
var ObjectExplosion = function() {
var that = new ObjectStatic();
that.name = 'explosion';
that.collide = function() {};
that.get_state = function() {
};
that.Explode = function(obj) {
var foobar = {};
foobar.id = 0;
foobar.name = 'Explode';
foobar.image = new Image();
foobar.image.src = 'images/explode.png';
foobar.breakable = function(foo) { return true; };
foobar.loop = false;
foobar.top = 6;
foobar.length = 4;
foobar.frames = new Array();
foobar.frames[0] = new Array();
foobar.frames[0].width = 76;
foobar.frames[0].height = 76;
foobar.frames[0].margin = 0;
foobar.frames[1] = new Array();
foobar.frames[1].width = 76;
foobar.frames[1].height = 76;
foobar.frames[1].margin = 0;
foobar.frames[2] = new Array();
foobar.frames[2].width = 76;
foobar.frames[2].height = 76;
foobar.frames[2].margin = 0;
foobar.frames[3] = new Array();
foobar.frames[3].width = 76;
foobar.frames[3].height = 76;
foobar.frames[3].margin = 0;
foobar.enter = function(sm, obj) {obj.frame = 0; };
foobar.update = function(sm, obj) {
if (obj.history.length === 0)
return false;
if (floor(obj.history[obj.history.length-1].frame) === 3) {
obj.destroy = true;
}
};
foobar.exit = function(sm) {
};
return foobar;
};
/*
* Create new State Machine
*/
that.sm = new EngineStateMachine();
that.sm.changeState( that.Explode(), that );
return that;
};
export { ObjectExplosion }