xxxxxxxxxx
52
class Particles {
constructor(name, estimate, error, xpos, ypos) {
this.title = name
this.error = error
this.Xpos = xpos
this.Ypos = ypos
this.timing = 30000000 / estimate
// this.remove = 1.01 * this.timing + this.timing
this.counter = 0
// this.counter2 = 0
this.particles = []
}
createParticles(xdir) {
let pos = createVector(this.Xpos, this.Ypos)
this.counter++
// this.counter2++
if (this.counter >= this.timing) {
this.particles.push(new Mover(pos, xdir))
this.counter = 0;
}
if (this.particles.length > 30) {
this.particles.splice(0, 1)
// this.counter2 = 0;
}
// console.log(this.particles.length)
}
display(target) {
for (var i = this.particles.length - 1; i >= 0; i--) {
this.particles[i].seek(target);
this.particles[i].update();
this.particles[i].display();
// console.log(this.particles.length)
}
}
}