Sha256: 1716ce28f01f0caad780f5602d8a10d7cfc82625b3c4bbdf8132a656f74dcfc8

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

# Crazy Flocking 3D Birds 
# by Ira Greenberg. 
# 
# Simulates a flock of birds using a Bird class and nested
# pushMatrix() / popMatrix() functions. 
# Trigonometry functions handle the flapping and sinuous movement.

load_library :bird 

BIRD_COUNT = 200

def setup  
  size 640, 360, P3D
  no_stroke
  lights
  @birds = []  
  0.upto(BIRD_COUNT) do |i|    
    bird = Bird.new rand(-300 .. 300), rand(-300 .. 300), rand(-2500 .. -500), rand(5 .. 30), rand(5 .. 30)    
    bird.set_flight rand(20 .. 340), rand(30 .. 350), rand( 1000 .. 4800 ),
    rand(-160 .. 160), rand(-55 .. 55), rand(-20 .. 20)    
    bird.set_wing_speed rand(0.1 .. 3.75)
    bird.set_rot_speed rand(0.025 .. 0.15)    
    @birds << bird
  end  
end

def draw  
  background 0  
  translate width/2, height/2, -700  
  @birds.each {|b| b.fly} 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-processing-2.4.4 samples/processing_app/basics/transform/birds.rb