class PirateGame::Wave

Constants

COLORS
OFFSET
SIZE

Public Class Methods

new(shoes, top) click to toggle source
Calls superclass method PirateGame::WavingItem::new
# File lib/pirate_game/wave.rb, line 8
def initialize shoes, top
  super rand(40), SIZE, 5

  @shoes = shoes
  @top   = top + OFFSET
  @arcs  = []
  @clear = @shoes.rgb 0, 0, 0, 0
end

Public Instance Methods

animate(frame) click to toggle source
# File lib/pirate_game/wave.rb, line 17
def animate frame
  top_offset, left_offset = waving_offset frame

  @arcs.each do |arc, top, left|
    arc.move top + top_offset, left + left_offset
  end
end
draw() click to toggle source
# File lib/pirate_game/wave.rb, line 25
def draw
  for i in (-3..12) do
    for j in [0,2,4] do
      color_index = (@seed + j) % COLORS.size
      @shoes.fill @clear
      @shoes.stroke COLORS[color_index]
      @shoes.strokewidth 3
      arc_dif = (j/360.0)*Shoes::TWO_PI

      top  = i * SIZE - j
      left = @top + j

      arc = @shoes.arc(i * SIZE - j, @top + j, SIZE + j, SIZE + j,
                       0 + arc_dif, Shoes::PI - arc_dif)

      @arcs << [arc, top, left]
    end
  end
end