flocking.pde

来自「This is processing for java examples.」· PDE 代码 · 共 33 行

PDE
33
字号
/** * 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(new PVector(width/2,height/2),2.0,0.05));  }  smooth();}void draw() {  background(50);  flock.run();}// Add a new boid into the Systemvoid mousePressed() {  flock.addBoid(new Boid(new PVector(mouseX,mouseY),2.0f,0.05f));}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?