Files
processing4/java/examples/Topics/Simulate/Flocking/Flock.pde
benfry eb64b2d4fc
2011-01-26 19:22:19 +00:00

23 lines
424 B
Plaintext

// 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);
}
}