Files
processing4/java/examples/Topics/Simulate/Flocking/Flocking.pde
2011-12-15 17:27:25 +00:00

32 lines
634 B
Plaintext

/**
* Flocking
* by Daniel Shiffman.
*
* An implementation of Craig Reynold's Boids program to simulate
* the flocking behavior of birds. Each boid steers itself based on
* rules of avoidance, alignment, and coherence.
*
* Click the mouse to add a new boid.
*/
Flock flock;
void setup() {
size(640, 360);
flock = new Flock();
// Add an initial set of boids into the system
for (int i = 0; i < 150; i++) {
flock.addBoid(new Boid(width/2,height/2));
}
}
void draw() {
background(50);
flock.run();
}
// Add a new boid into the System
void mousePressed() {
flock.addBoid(new Boid(mouseX,mouseY));
}