Class: Explosion
- Inherits:
-
Object
- Object
- Explosion
- Defined in:
- lib/rrobots/explosion.rb
Instance Attribute Summary collapse
-
#dead ⇒ Object
Returns the value of attribute dead.
-
#t ⇒ Object
Returns the value of attribute t.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(bf, x, y) ⇒ Explosion
constructor
A new instance of Explosion.
- #state ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(bf, x, y) ⇒ Explosion
Returns a new instance of Explosion.
7 8 9 10 |
# File 'lib/rrobots/explosion.rb', line 7 def initialize bf, x, y @x, @y, @t = x, y, 0 @battlefield, dead = bf, false end |
Instance Attribute Details
#dead ⇒ Object
Returns the value of attribute dead.
5 6 7 |
# File 'lib/rrobots/explosion.rb', line 5 def dead @dead end |
#t ⇒ Object
Returns the value of attribute t.
4 5 6 |
# File 'lib/rrobots/explosion.rb', line 4 def t @t end |
#x ⇒ Object
Returns the value of attribute x.
2 3 4 |
# File 'lib/rrobots/explosion.rb', line 2 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
3 4 5 |
# File 'lib/rrobots/explosion.rb', line 3 def y @y end |
Instance Method Details
#state ⇒ Object
12 13 14 |
# File 'lib/rrobots/explosion.rb', line 12 def state {:x=>x, :y=>y, :t=>t} end |
#tick ⇒ Object
16 17 18 19 |
# File 'lib/rrobots/explosion.rb', line 16 def tick @t += 1 @dead ||= t > 15 end |