Class: PirateGame::Image

Inherits:
WavingItem show all
Defined in:
lib/pirate_game/image.rb

Instance Attribute Summary

Attributes inherited from WavingItem

#speed

Instance Method Summary collapse

Methods inherited from WavingItem

#waving_offset

Constructor Details

#initialize(shoes, image, top, left) ⇒ Image

Returns a new instance of Image.



3
4
5
6
7
8
9
10
# File 'lib/pirate_game/image.rb', line 3

def initialize shoes, image, top, left
  super 0, 10, 4

  @shoes = shoes
  @image = image
  @top   = top
  @left  = left
end

Instance Method Details

#animate(frame) ⇒ Object



12
13
14
15
16
# File 'lib/pirate_game/image.rb', line 12

def animate frame
  top_offset, left_offset = waving_offset frame

  @ship.move @top + top_offset, @left + left_offset
end

#drawObject



18
19
20
# File 'lib/pirate_game/image.rb', line 18

def draw
  @ship = @shoes.image @image, top: @top, left: @left
end