-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemies.js
38 lines (33 loc) · 818 Bytes
/
enemies.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
function Enemy(x, y) {
this.x = x;
this.y = y;
this.width = 20;
this.height = 15;
this.dead = false;
this.animation = 1;
this.animCooldown = -1;
this.show = function() {
//fill(255, 0, 120);
//imageMode(CENTER);
image(enemySprites[this.animation], this.x - this.width / 2, this.y, this.width, this.height);
}
this.updatePos = function(x, y) {
if (this.animCooldown < 0) {
this.animate();
}
this.x = x;
this.y = y;
this.animCooldown--;
}
this.die = function() {
this.dead = true;
}
this.animate = function() {
if (this.animation >= 3) {
this.animation = 1;
} else {
this.animation++;
}
this.animCooldown = 20;
}
}