mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 17:40:48 +01:00
26 lines
516 B
Plaintext
26 lines
516 B
Plaintext
// Flocking
|
|
// Daniel Shiffman <http://www.shiffman.net>
|
|
// The Nature of Code, Spring 2011
|
|
|
|
// Flock class
|
|
// Does very little, simply manages the ArrayList of all the boids
|
|
|
|
class Flock {
|
|
ArrayList<Boid> boids; // An ArrayList for all the boids
|
|
|
|
Flock() {
|
|
boids = new ArrayList<Boid>(); // Initialize the ArrayList
|
|
}
|
|
|
|
void run() {
|
|
for (Boid b : boids) {
|
|
b.run(boids); // Passing the entire list of boids to each boid individually
|
|
}
|
|
}
|
|
|
|
void addBoid(Boid b) {
|
|
boids.add(b);
|
|
}
|
|
|
|
}
|