xxxxxxxxxx
41
class Cacti {
constructor(t) {
this.type = t;
this.vx = 7;
switch (this.type) {
case 0: //small cactus
this.w = 30;
this.h = 70;
break;
case 1: //big cactus
this.w = 40;
this.h = 80;
break;
}
this.x = width;
this.y = height - this.h;
}
move() {
this.x -= this.vx;
}
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;
}
// noFill();
// rect(this.x, this.y +20, this.w, this.h);
}
}