mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 11:51:54 +01:00
27 lines
552 B
Plaintext
27 lines
552 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() {
|
|
for (int i = particles.size()-1; i >= 0; i--) {
|
|
Particle p = particles.get(i);
|
|
p.run();
|
|
if (p.isDead()) {
|
|
particles.remove(i);
|
|
}
|
|
}
|
|
}
|
|
}
|