Class: PirateGame::BridgeButton
- Inherits:
-
WavingItem
- Object
- WavingItem
- PirateGame::BridgeButton
- Defined in:
- lib/pirate_game/bridge_button.rb
Constant Summary collapse
- TOP =
150
Instance Attribute Summary
Attributes inherited from WavingItem
Instance Method Summary collapse
- #animate(frame) ⇒ Object
- #draw ⇒ Object
-
#initialize(shoes, text, row, column, &click_action) ⇒ BridgeButton
constructor
A new instance of BridgeButton.
Methods inherited from WavingItem
Constructor Details
#initialize(shoes, text, row, column, &click_action) ⇒ BridgeButton
Returns a new instance of BridgeButton.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pirate_game/bridge_button.rb', line 5 def initialize shoes, text, row, column, &click_action super rand(90), 10, 4 @shoes = shoes @text = text @row = row @column = column @click_action = click_action = nil @left = nil @top = nil end |
Instance Method Details
#animate(frame) ⇒ Object
19 20 21 22 23 |
# File 'lib/pirate_game/bridge_button.rb', line 19 def animate frame top_offset, left_offset = waving_offset frame .move @top + top_offset, @left + left_offset end |
#draw ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pirate_game/bridge_button.rb', line 25 def draw width = @shoes.app.width chunk = width / 6 # something is wrong in my head, these are switched @top = chunk / 3 + 2 * @column * chunk @left = TOP + @row * 40 = @shoes. @text, &@click_action .move @left, @top end |