topical media & game development

talk show tell print

graphic-processing-site-examples-Topics-Simulate-Flocking-Flock.pde / pde



  // The Flock (a list of Boid objects)
  
  class Flock {
    ArrayList boids; // An arraylist for all the boids
  
    Flock() {
      boids = new ArrayList(); // Initialize the arraylist
    }
  
    void run() {
      for (int i = 0; i < boids.size(); i++) {
        Boid b = (Boid) boids.get(i);  
        b.run(boids);  // Passing the entire list of boids to each boid individually
      }
    }
  
    void addBoid(Boid b) {
      boids.add(b);
    }
  
  }
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.