mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 11:51:54 +01:00
28 lines
563 B
Plaintext
28 lines
563 B
Plaintext
// A class to describe a group of Particles
|
|
// An ArrayList is used to manage the list of Particles
|
|
|
|
class ParticleSystem {
|
|
ArrayList<Particle> particles;
|
|
PVector origin;
|
|
|
|
ParticleSystem(PVector location) {
|
|
origin = location.get();
|
|
particles = new ArrayList<Particle>();
|
|
}
|
|
|
|
void addParticle() {
|
|
particles.add(new Particle(origin));
|
|
}
|
|
|
|
void run() {
|
|
Iterator<Particle> it = particles.iterator();
|
|
while (it.hasNext()) {
|
|
Particle p = it.next();
|
|
p.run();
|
|
if (p.isDead()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|