# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# boids.Boids.boids[]

## Syntax

    flock.boids(index)

## Description

The list of all individual boids in a flock. When you want to draw each boid to the canvas, you can loop through this list and access each boid's properties:

- boid.x: the boid's horizontal position
- boid.y: the boid's vertical position
- boid.z: the boid's depth
- boid.angle(): the direction the boid is facing, its 2D-rotation.
- boid.fill: the boid's fill color.

## Example

A flock of ten boids flying around the screen:

    size(500,500)
    speed(100)

    def setup():

      boids = ximport("boids")
      global flock
      flock = boids.flock(10, 0, 0, WIDTH, HEIGHT)

    def draw():

      global flock
      flock.update()

      for boid in flock.boids:
        r = 10 + boid.z / 4
        f = boid.fill
        f.a = 0.5+ boid.z/100
        fill(f)
        push()
        rotate(-boid.angle())
        arrow(boid.x-r/2, boid.y-r/2, r)
        pop()