-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathobstacles.js
45 lines (39 loc) · 828 Bytes
/
obstacles.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
class Cacti {
constructor(t) {
this.type = t;
switch (this.type) {
case 0: //small cactus
this.w = 40;
this.h = 80;
break;
case 1: //big cactus
this.w = 60;
this.h = 120;
break;
case 2: //small cacti
this.w = 120;
this.h = 80;
break;
}
this.x = width;
this.y = height - this.h - gapFromBottom;
}
move() {
this.x -= speed;
}
show() {
switch (this.type) {
case 0:
image(cactusSmall, this.x, this.y, this.w, this.h);
break;
case 1:
image(cactusBig, this.x, this.y, this.w, this.h);
break;
case 2:
image(cacti, this.x, this.y, this.w, this.h);
break;
}
// noFill();
// rect(this.x, this.y +20, this.w, this.h);
}
}