class SpaceInvaders::DrownedShipAnimator
Constants
- ANIMATION_LENGTH_IN_SECONDS
Attributes
ship[RW]
Public Class Methods
new(app, ship)
click to toggle source
Calls superclass method
SpaceInvaders::Base::new
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 8 def initialize(app, ship) super(app) @ship = ship end
Public Instance Methods
animation_time_is_over?()
click to toggle source
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 17 def animation_time_is_over? passed_time > ANIMATION_LENGTH_IN_SECONDS end
reset!()
click to toggle source
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 21 def reset! @start_time = nil end
start!()
click to toggle source
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 13 def start! @start_time = Time.now end
update()
click to toggle source
# 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
Private Instance Methods
left_image_time?()
click to toggle source
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 42 def left_image_time? (passed_time * 10 % 10).round.even? end
passed_time()
click to toggle source
# File lib/space_invaders/ship/drowned_ship_animator.rb, line 38 def passed_time Time.now - @start_time end