Class: Asteroids::ExplosionGraphics
- Defined in:
- lib/asteroids/explosion/explosion_graphics.rb
Constant Summary collapse
- FRAME_DELAY =
17
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(game_object) ⇒ ExplosionGraphics
constructor
A new instance of ExplosionGraphics.
- #update ⇒ Object
Constructor Details
#initialize(game_object) ⇒ ExplosionGraphics
Returns a new instance of ExplosionGraphics.
6 7 8 9 |
# File 'lib/asteroids/explosion/explosion_graphics.rb', line 6 def initialize(game_object) super @current_frame = 0 end |
Instance Method Details
#draw ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/asteroids/explosion/explosion_graphics.rb', line 12 def draw() image = current_frame image.draw( object.x - image.width / 2.0, object.y - image.height / 2.0, 100) end |
#update ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/asteroids/explosion/explosion_graphics.rb', line 20 def update now = Gosu.milliseconds delta = now - (@last_frame ||= now) if delta > FRAME_DELAY @last_frame = now end @current_frame += (delta / FRAME_DELAY).floor object.mark_for_removal if done? end |