xxxxxxxxxx
34
class ParticalSystem {
constructor() {
this.particals = [];
}
addPartical(x,y) {
this.particals.push(new Partical(x,y));
}
updateParticals() {
for(let i = 0; i < this.particals.length; i++) {
this.particals[i].update();
if(this.particals[i].lifetime % 20 == 0) {
this.explode(i);
}
if(this.particals.length > 68) {
this.particals.shift();
}
}
print(this.particals.length);
}
explode(idx) {
for(let i = 0; i < 5; i++) {
this.particals.splice(idx, 0, new EPartical(this.particals[idx].pos.x + random(-50, 50), this.particals[idx].pos.x + random(-30, -50)));
}
}
showParticals() {
for(let partical of this.particals) {
partical.show();
}
}
}