xxxxxxxxxx
27
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Particles are generated each cycle through draw(),
// fall with gravity and fade out over time
// A ParticleSystem object manages a variable size
// list of particles.
// an array of ParticleSystems
let emitters = [];
function setup() {
createCanvas(640, 240);
}
function draw() {
background(255);
for (let emitter of emitters) {
emitter.run();
emitter.addParticle();
}
}
function mousePressed() {
emitters.push(new Emitter(mouseX, mouseY));
}