mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 19:31:16 +01:00
22 lines
380 B
Plaintext
22 lines
380 B
Plaintext
// The Flock (a list of Boid objects)
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|