class TankHealth

Constants

RESPAWN_DELAY

Attributes

health[RW]

Public Class Methods

new(object, object_pool) click to toggle source
Calls superclass method Health::new
# File lib/entities/components/tank_health.rb, line 5
def initialize(object, object_pool)
  super(object, object_pool, 100, true)
end

Public Instance Methods

should_respawn?() click to toggle source
# File lib/entities/components/tank_health.rb, line 9
def should_respawn?
  if @death_time
    Gosu.milliseconds - @death_time > RESPAWN_DELAY
  end
end

Protected Instance Methods

after_death(cause) click to toggle source
# File lib/entities/components/tank_health.rb, line 21
def after_death(cause)
  @death_time = Gosu.milliseconds
  object.reset_modifiers
  object.input.stats.add_death
  kill = object != cause ? 1 : -1
  cause.input.stats.add_kill(kill)
  Thread.new do
    sleep(rand(0.1..0.3))
    Explosion.new(@object_pool, x, y, cause)
  end
end
draw?() click to toggle source
# File lib/entities/components/tank_health.rb, line 17
def draw?
  true
end