class Flock

Attributes

members[R]

Public Class Methods

new() click to toggle source
# File examples/ruboids/ruboids/Flock.rb, line 15
def initialize
    @members = []
end

Public Instance Methods

add(boid) click to toggle source
# File examples/ruboids/ruboids/Flock.rb, line 19
def add(boid)
    @members << boid
    boid.flock = self
end
centerExcluding(b) click to toggle source

Center of mass

# File examples/ruboids/ruboids/Flock.rb, line 38
def centerExcluding(b)
    p = Point.new()
    @members.each { | boid |
        p.addPoint(boid.position) unless boid == b
    }
    p.divideBy(@members.length - 1)
    return p
end
distBetween(b1, b2) click to toggle source

Return distance between two boid's positions.

# File examples/ruboids/ruboids/Flock.rb, line 33
def distBetween(b1, b2)
    return b1.position.distanceTo(b2.position)
end
draw() click to toggle source
# File examples/ruboids/ruboids/Flock.rb, line 24
def draw
    @members.each { | boid | boid.draw() }
end
move() click to toggle source
# File examples/ruboids/ruboids/Flock.rb, line 28
def move
    @members.each { | boid | boid.move() }
end