Class: Bomb

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Tileable

included

Constructor Details

#initialize(x, y) ⇒ Bomb

Returns a new instance of Bomb.



5
6
7
8
9
10
11
12
# File 'lib/bomb.rb', line 5

def initialize(x,y)
  register!(x, y)
  @t_size       = Processor::TileSize
  @sprites      = Gosu::Image.load_tiles(Processor.window, BLAST_IMG_PATH + "dynamite.png", @t_size, @t_size, false)
  @time_counter = 80
  @sprite_index = 0
  @solid        = false
end

Instance Attribute Details

#solidObject

Returns the value of attribute solid.



3
4
5
# File 'lib/bomb.rb', line 3

def solid
  @solid
end

#time_counterObject

Returns the value of attribute time_counter.



3
4
5
# File 'lib/bomb.rb', line 3

def time_counter
  @time_counter
end

Instance Method Details

#drawObject



14
15
16
17
# File 'lib/bomb.rb', line 14

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

#solid_at?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bomb.rb', line 25

def solid_at?(x, y)
  @solid && at?(x, y)
end

#updateObject



19
20
21
22
23
# File 'lib/bomb.rb', line 19

def update
  @time_counter -= 1
  @sprite_index += 1 if @time_counter % 20 == 0
  @sprite_index = 3 if @sprite_index > 3
end