xxxxxxxxxx
39
class Pack {
constructor(x, y, n, startAngle) {
this.x = x;
this.y = y
this.n = n;
this.pack = [];
this.packr = 150;
this.angle = 180/this.n;
this.startAngle = startAngle;
this.createCircle();
}
createCircle(){
let scl = 0.1;
for (let i=0; i<this.n; i++){
this.pack[i] = new Circle(this.x + this.packr*cos(this.startAngle + i*this.angle), this.y + this.packr*sin(this.startAngle + i*this.angle), (i+1)*scl*25, 0.5);
}
}
displayPack() {
for (let i=0; i<this.n; i++){
this.pack[i].display();
this.pack[i].move(0, 30);
}
}
move(speed) {
this.startAngle += speed;
for (let i=0; i<this.n; i++){
this.pack[i].x = this.x + this.packr*cos(this.startAngle + i*this.angle);
this.pack[i].y = this.y + this.packr*sin(this.startAngle + i*this.angle);
}
}
}