Class: SpaceInvaders::DrownedShipAnimator
- Defined in:
- lib/space_invaders/ship/drowned_ship_animator.rb
Constant Summary collapse
- ANIMATION_LENGTH_IN_SECONDS =
2
Instance Attribute Summary collapse
-
#ship ⇒ Object
Returns the value of attribute ship.
Attributes inherited from Base
Instance Method Summary collapse
- #animation_time_is_over? ⇒ Boolean
-
#initialize(app, ship) ⇒ DrownedShipAnimator
constructor
A new instance of DrownedShipAnimator.
- #reset! ⇒ Object
- #start! ⇒ Object
- #update ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app, ship) ⇒ DrownedShipAnimator
Returns a new instance of DrownedShipAnimator.
8 9 10 11 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 8 def initialize(app, ship) super(app) @ship = ship end |
Instance Attribute Details
#ship ⇒ Object
Returns the value of attribute ship.
6 7 8 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 6 def ship @ship end |
Instance Method Details
#animation_time_is_over? ⇒ Boolean
17 18 19 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 17 def animation_time_is_over? passed_time > ANIMATION_LENGTH_IN_SECONDS end |
#reset! ⇒ Object
21 22 23 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 21 def reset! @start_time = nil end |
#start! ⇒ Object
13 14 15 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 13 def start! @start_time = Time.now end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/space_invaders/ship/drowned_ship_animator.rb', line 25 def update ship.image = if animation_time_is_over? app.game_status.continue! app.images.ship elsif left_image_time? app.images.ship_crushed_left else app.images.ship_crushed_right end end |