xxxxxxxxxx
31
class Bran {
constructor() {
this.x = random(50, 550);
this.y = 0;
this.speed = 3 + random(0, 7);
this.diameter = 70;
image(branImg, this.x, this.y, this.diameter, this.diameter + 10);
}
display() {
noFill();
noStroke();
ellipse(this.x, this.y, this.diameter);
imageMode(CENTER);
image(branImg, this.x, this.y, this.diameter, this.diameter + 10);
}
move() {
this.y += this.speed;
//re-generate Brans at top of screen when Brans fall off screen at the bottom
if (this.y - this.diameter / 2 > canvas.height) {
this.reset();
}
}
reset() {
this.x = random(50, 550);
this.y = 0;
}
}