Class: Bomb
Instance Attribute Summary collapse
-
#solid ⇒ Object
Returns the value of attribute solid.
-
#time_counter ⇒ Object
Returns the value of attribute time_counter.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(x, y) ⇒ Bomb
constructor
A new instance of Bomb.
- #solid_at?(x, y) ⇒ Boolean
- #update ⇒ Object
Methods included from Tileable
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
#solid ⇒ Object
Returns the value of attribute solid.
3 4 5 |
# File 'lib/bomb.rb', line 3 def solid @solid end |
#time_counter ⇒ Object
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
#draw ⇒ Object
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
25 26 27 |
# File 'lib/bomb.rb', line 25 def solid_at?(x, y) @solid && at?(x, y) end |
#update ⇒ Object
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 |