Class: Explosion
Instance Attribute Summary collapse
-
#time_counter ⇒ Object
Returns the value of attribute time_counter.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(x, y) ⇒ Explosion
constructor
A new instance of Explosion.
- #update ⇒ Object
Methods included from Tileable
Constructor Details
#initialize(x, y) ⇒ Explosion
Returns a new instance of Explosion.
5 6 7 8 9 10 11 |
# File 'lib/explosion.rb', line 5 def initialize(x,y) register!(x, y) @t_size = Processor::TileSize @sprites = Gosu::Image.load_tiles(Processor.window, BLAST_IMG_PATH + "explosion.png", @t_size, @t_size, false) @time_counter = 20 @sprite_index = 0 end |
Instance Attribute Details
#time_counter ⇒ Object
Returns the value of attribute time_counter.
3 4 5 |
# File 'lib/explosion.rb', line 3 def time_counter @time_counter end |
Instance Method Details
#draw ⇒ Object
13 14 15 16 |
# File 'lib/explosion.rb', line 13 def draw @sprites[@sprite_index].draw(top_x, top_y, 2) update end |
#update ⇒ Object
18 19 20 21 |
# File 'lib/explosion.rb', line 18 def update @time_counter -= 1 @sprite_index += 1 if @time_counter % 2 == 0 end |