Class: RTanque::Gui::Explosion
- Inherits:
-
Object
- Object
- RTanque::Gui::Explosion
- Defined in:
- lib/rtanque/gui/explosion.rb
Constant Summary collapse
- FRAMES =
(1..71)
Instance Method Summary collapse
- #draw ⇒ Object
- #frame ⇒ Object
-
#initialize(window, explosion) ⇒ Explosion
constructor
A new instance of Explosion.
Constructor Details
#initialize(window, explosion) ⇒ Explosion
Returns a new instance of Explosion.
8 9 10 11 12 13 |
# File 'lib/rtanque/gui/explosion.rb', line 8 def initialize(window, explosion) @window = window @explosion = explosion @position = [explosion.position.x, window.height - explosion.position.y] @explosion_images = FRAMES.map { |i| Gosu::Image.new(@window, Gui.resource_path("images/explosions/explosion2-#{i}.png")) } end |
Instance Method Details
#draw ⇒ Object
15 16 17 |
# File 'lib/rtanque/gui/explosion.rb', line 15 def draw frame.draw_rot(@position[0], @position[1], 5, ZOrder::EXPLOSION) end |
#frame ⇒ Object
19 20 21 22 |
# File 'lib/rtanque/gui/explosion.rb', line 19 def frame @frames_length ||= @explosion_images.length - 1 @explosion_images[(@explosion.percent_dead * @frames_length).floor] end |