mirror of
https://github.com/processing/processing4.git
synced 2026-04-21 11:44:23 +02:00
adding the topics as well
This commit is contained in:
22
android/examples/Topics/Simulate/Flocking/Flock.pde
Normal file
22
android/examples/Topics/Simulate/Flocking/Flock.pde
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user