xxxxxxxxxx
31
// Click screen to shoot balloons
class Balloon {
constructor() {
this.d = random(20, 70);
this.red = 255;
this.xPosition = random(width);
this.yPosition = random(width, width + 100);
this.ySpeed = 2
}
float() {
this.yPosition -= this.ySpeed
}
position() {
this.color = map(this.yPosition, 400, 50, 0, 255);
noStroke();
fill(255, this.color, this.color);
ellipse(this.xPosition, this.yPosition, this.d);
}
contains(x, y) {
let d = dist(x, y, this.xPosition, this.yPosition);
if (this.d / 2 > d) {
return true
} else {
return false
}
}
}