Class: PirateGame::Wave
- Inherits:
-
WavingItem
- Object
- WavingItem
- PirateGame::Wave
- Defined in:
- lib/pirate_game/wave.rb
Constant Summary collapse
- COLORS =
PirateGame::Boot::BLUE_COLORS + PirateGame::Boot::GREEN_COLORS
- OFFSET =
210
- SIZE =
40
Instance Attribute Summary
Attributes inherited from WavingItem
Instance Method Summary collapse
- #animate(frame) ⇒ Object
- #draw ⇒ Object
-
#initialize(shoes, top) ⇒ Wave
constructor
A new instance of Wave.
Methods inherited from WavingItem
Constructor Details
Instance Method Details
#animate(frame) ⇒ Object
17 18 19 20 21 22 23 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 |