Sha256: 157e470a9595a346823e7c86bda81238a4ab5158f9feb38fcc068eb4a7aef903

Contents?: true

Size: 616 Bytes

Versions: 6

Compression:

Stored size: 616 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_libraries :flock, :vecmath

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

6 entries across 6 versions & 1 rubygems

Version Path
ruby-processing-2.6.2 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.6.1 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.6.0 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.5.1 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.5.0 samples/processing_app/topics/simulate/flocking.rb
ruby-processing-2.4.4 samples/processing_app/topics/simulate/flocking.rb