// Simple Particle System // Daniel Shiffman // Click the mouse to generate a burst of particles // at mouse location // Each burst is one instance of a particle system // with Particles and CrazyParticles (a subclass of Particle) // Note use of Inheritance and Polymorphism here // Created 2 May 2005 import noc.*; int totalThings = 50; PFont f; ArrayList bsystems; boolean showvalues = false; int trailAmount = 15; void setup() { size(600,600); colorMode(RGB,255,255,255,100); setupScrollbars(); f = loadFont("Arial-BoldMT-12.vlw"); bsystems = new ArrayList(); bsystems.add(new BoidSystem(totalThings,new Vector3D(width/2,height/2))); smooth(); } void draw() { // background(0); fill(0,trailAmount); rect(0,0,width,height); // Cycle through all particle systems, run them and delete old ones for (int i = bsystems.size()-1; i >= 0; i--) { BoidSystem bsys = (BoidSystem) bsystems.get(i); bsys.run(); } } void keyPressed() { showvalues = !showvalues; }