// Use a single flocking system FlockSystem fs; void setup() { // setup the environment size(600, 500); colorMode(RGB, 255, 255, 255, 100); smooth(); // Setup the flockSystem fs = new FlockSystem(); // Add 25 boids to start for (int i = 0; i < 25; i++) { // each new boid we add to the system has 3 parameters: // // Vector3D => Starting position // 4.0f => Max velocity // 0.1f => Max accelerating force fs.addParticle(new Boid(new Vector3D(width / 2, height / 2, 0), 4.0f, 0.1f)); } } void draw() { background(240); fs.simulate(); } void mousePressed() { fs.addParticle(new Boid(new Vector3D(mouseX, mouseY, 0), 5.0f, 0.1f)); }