Class: RTanque::Gui::Explosion

Inherits:
Object
  • Object
show all
Defined in:
lib/rtanque/gui/explosion.rb

Constant Summary collapse

FRAMES =
(1..71)

Instance Method Summary collapse

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

#drawObject


15
16
17
# File 'lib/rtanque/gui/explosion.rb', line 15

def draw
  frame.draw_rot(@position[0], @position[1], 5, ZOrder::EXPLOSION)
end

#frameObject


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