Files
processing4/java/examples/Demos/Graphics/Particles/ParticleSystem.pde
Casey Reas 3494890075
2012-08-31 03:10:40 +00:00

37 lines
623 B
Plaintext

class ParticleSystem {
ArrayList<Particle> particles;
PShape particleShape;
ParticleSystem(int n) {
particles = new ArrayList<Particle>();
particleShape = createShape(PShape.GROUP);
for (int i = 0; i < n; i++) {
Particle p = new Particle();
particles.add(p);
particleShape.addChild(p.getShape());
}
}
void update() {
for (Particle p : particles) {
p.update();
}
}
void setEmitter(float x, float y) {
for (Particle p : particles) {
if (p.isDead()) {
p.rebirth(x, y);
}
}
}
void display() {
shape(particleShape);
}
}