Esempio n. 1
0
  /**
   * Creates an empty flock.
   *
   * @param parent the PApplet that hosts this class
   */
  public Flock(Flocking applet) {
    p = applet;
    boids = new ArrayList<Boid>();

    // Size the cells so that we never have to search more
    // than four cells.
    float cellSize = 2.0f * Boid.getNeighborhoodSize();
    int cellsX = (int) (p.width / cellSize);
    int cellsY = (int) (p.height / cellSize);

    csp = new CellSpacePartition<Boid>(p.width, p.height, cellsX, cellsY);
  }