Sha256: 0117524367c2c2dc98b4f757514f492a085451d80545c33e9131734e788732ac

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

#
# 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.
#
load_library :flock

attr_reader :flock

def setup
  size(640, 360)
  @flock = Flock.new
  # Add an initial set of boids into the system
  150.times do
    flock << Boid.new(width/2, height/2)
  end
end

def draw
  background(50)
  flock.run
end

# Add a new boid into the System
def mouse_pressed
  flock << Boid.new(mouse_x, mouse_y)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-processing-2.4.3 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.4.2 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.4.1 samples/processing_app/topics/simulate/flocking.rb