xxxxxxxxxx
35
class Pack {
constructor(x, y, pr) {
this.x = x;
this.y = y;
this.n = 4;
this.pack = [];
this.num = 50;
this.pr = pr;
this.m = 0;
for (let i=0; i<this.n; i++) {
this.pack[i] = new Circle(colors[i%3], i*50, this.pr+i*5, i+1, this.num/(i+1), this.num);
}
}
display() {
for (let i=0; i<this.n; i++) {
push();
translate(this.x, this.y);
this.move();
this.pack[i].display(this.m);
pop();
}
}
move() {
let distance = dist(mouseX, mouseY, this.x, this.y);
if (distance < 50) {
this.m = floor(distance/10) + 1;
} else {
this.m = 0;
}
}
}