Sha256: e1ac101ea84986aa8cdfa9f35b3b588e24ecc1c41f90a76024442811fdd4acb2

Contents?: true

Size: 674 Bytes

Versions: 6

Compression:

Stored size: 674 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 :vecmath # load_library required by flock library 
load_library :flock

attr_reader :flock

def setup
  size(640, 360)
  # Add an initial set of boids into the system at the center
  @flock = Flock.new(150, Vec2D.new(width / 2.0, height / 2.0))
end

def draw
  background(50)
  flock.run
end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/library/vecmath/vec2d/flocking.rb
ruby-processing-2.6.2 samples/processing_app/library/vecmath/vec2d/flocking.rb
ruby-processing-2.6.1 samples/processing_app/library/vecmath/vec2d/flocking.rb
ruby-processing-2.6.0 samples/processing_app/library/vecmath/vec2d/flocking.rb
ruby-processing-2.5.1 samples/processing_app/library/vecmath/vec2d/flocking.rb
ruby-processing-2.5.0 samples/processing_app/library/vecmath/vec2d/flocking.rb