blob: 33a068d29c2246884f14ad1f749fa73f4ae22c7e (
plain)
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
|
(function(window) {
var Gag = function(cat, x, y, dir) {
this.initialize(cat, x, y, dir);
}
var p = Gag.prototype = new Container();
Gag.initialize = function() {
Gag.img = new Image();
Gag.img.onload = function() {
Gag.gfx = new Bitmap(Gag.img);
}
Gag.img.src = "catgag.png";
}
Gag.initialize();
Gag.count = 0;
p.escaped = false;
p.dir = 0;
p.cat = null;
p.base_initialize = p.initialize;
p.initialize = function(cat, x, y, dir) {
p.base_initialize();
this.id = Gag.count;
Gag.count++;
this.x = x;
this.y = y;
this.dir = dir;
this.cat = cat;
this.gfx = new Bitmap(Gag.img);
this.addChild(this.gfx);
cat.getStage().addChild(this);
}
p.tick = function() {
if (!this.escaped && !this.rect().collidesWith(this.cat.rect())) {
this.escaped = true;
window.Log("(" + this.id + ") " + this.x + "," + this.y + " escaped");
}
this.x += Math.cos(this.dir * Math.PI / 180.0) * 2;
this.y += Math.sin(this.dir * Math.PI / 180.0) * 2;
}
p.rect = function() {
return new Rectangle(this.x, this.y, Gag.img.width, Gag.img.height);
}
window.Gag = Gag;
}(window))
|