-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmultiplier.js
56 lines (41 loc) · 1.09 KB
/
multiplier.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
// --- inherits from game_object
// spec:
// game_object spec
var multiplier = function(p, spec) {
// --- defaults ---
spec.width = spec.width || 5;
spec.height = spec.height || 5;
// make sure it goes left
spec.vel = new p.PVector(p.random(0, -1)* g_speed_factor, p.random()* g_speed_factor);
// obj to return
var obj = game_object(p, spec);
obj.get_type = function() {
return "multiplier";
};
// --- private variables ---
var alive = true;
// --- public methods ---
// implementing game_object interface
obj.update = function() {
obj.bounce();
obj.move();
};
// (rectangle for now)
obj.draw = function() {
var pos = obj.get_pos();
var w = obj.get_width();
var h = obj.get_height();
p.shapeMode(obj.mode);
p.fill(0, 255, 0);
p.noStroke();
p.ellipse(pos.x, pos.y,
obj.get_width(), obj.get_height());
};
obj.die = function() {
alive = false;
}
obj.is_dead = function() {
return (!alive);
};
return obj;
};