Class: Explosion

Inherits:
Object
  • Object
show all
Includes:
Tileable
Defined in:
lib/explosion.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Tileable

included

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_counterObject

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

#drawObject



13
14
15
16
# File 'lib/explosion.rb', line 13

def draw
  @sprites[@sprite_index].draw(top_x, top_y, 2)
  update
end

#updateObject



18
19
20
21
# File 'lib/explosion.rb', line 18

def update
  @time_counter -= 1
  @sprite_index += 1 if @time_counter % 2 == 0
end