// Built With Processing // Craig Anthony Perkins // http://www.processing.org // Declaring a global variable of type ArrayList ArrayList particles; void setup() { size(400,400); particles = new ArrayList(); smooth(); } void draw() { background(255,155,25); // Add a new particle at mouse location particles.add(new Particle(mouseX,mouseY)); // Loop through all Particles for (int i = particles.size() - 1; i >= 0; i-- ) { Particle p = (Particle) particles.get(i); p.run(); p.gravity(); p.display(); // If the particle is no longer needed, it is deleted from the list if (p.finished()) { particles.remove(i); } } }