class Cloud
Attributes
bubbles[R]
speed[R]
width[R]
Public Class Methods
new()
click to toggle source
# File examples/ruboids/ruboids/Cloud.rb, line 30 def initialize minSpeed = $PARAMS['cloud_min_speed'] minBubbles = $PARAMS['cloud_min_bubbles'] @speed = rand($PARAMS['cloud_max_speed'] - minSpeed) + minSpeed numBubbles = rand($PARAMS['cloud_max_bubbles'] - minBubbles) + minBubbles @bubbles = [] prevBubble = nil (0 ... numBubbles).each { | i | bubble = Bubble.new() if !prevBubble.nil? bubble.loc.x = prevBubble.loc.x + rand((prevBubble.radius + bubble.radius) * 0.66) end @bubbles[i] = prevBubble = bubble } @width = bubbles.last.loc.x + @bubbles.first.radius + @bubbles.last.radius @view = CloudView.new(self) end
Public Instance Methods
move()
click to toggle source
# File examples/ruboids/ruboids/Cloud.rb, line 54 def move @position.x += pixelsPerSecToPixelsPerMove(speed) halfWorldWidth = $PARAMS['world_width'] if (@position.x >= halfWorldWidth / 2) @position.x = -(halfWorldWidth + @width) end end