NodeBox

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

boids.Boids.scatter()

Syntax

flock.scatter(chance=0.005, frames=50)

Description

Sometimes a flock of boids may scatter due to confusion or a predator. The scatter() method sets this dispersion with a percentual chance (between 0.0 and 1.0) each boids.Boids.update() of scattering, and the confusion remaining for a duration of the given frames.

When the flock scatters. the boids' cohesion is negated, and their joint alignment is slightly diminished.

Example

A totally chaotic flock:

boids = ximport("boids")
flock = boids.flock(10, 0, 0, WIDTH, HEIGHT)
flock.scatter(chance=1)

for i in range(10):
  flock.update()