xxxxxxxxxx
48
class Bubble
{
constructor(x, y, r, power, img)
{
this.x = x;
this.y = y;
this.r = r;
this.power = power;
this.color = 0;
this.img = img;
}
move()
{
this.x += random(-this.power, this.power);
this.y += random(-this.power, this.power);
}
show()
{
// strokeWeight(5);
// stroke(255);
// fill(this.color);
// ellipse(this.x, this.y, this.r, this.r);
image(this.img, this.x, this.y, this.r, this.r);
}
containsPointer(px, py)
{
return (px > this.x && px < this.x + this.r && py > this.y && py < this.y + this.r);
}
containsOtherCircle(other)
{
let d = dist(this.x, this.y, other.x, other.y);
return (d < this.r + other.r);
}
changeColor(color)
{
this.color = color;
}
changeRandomImage()
{
this.img = random(imgs);
}
}