if self.health <= 0.0 then die(world)
end
- # Die in the game logic, with graphical animations and scoring when applicable
+ # Die in the game logic, with graphical animations
#
# Calls `destroy` by default.
fun die(world: World)
do
+ if not is_alive then return
is_alive = false
destroy world
end
# Destroy this objects and most references to it
- fun destroy(world: World) do end
+ protected fun destroy(world: World) do end
# ---
# Box services
redef fun die(world)
do
+ if not is_alive then return
super
world.explode(center, width)
world.score += 1
for plane in world.planes do # TODO optimize with quad tree
if plane.left < right and plane.right > left then
if old_y > plane.top and bottom <= plane.top then
- if world.parachute != null then
- world.parachute.destroy(world)
+ var parachute = world.parachute
+ if parachute != null then
+ parachute.die world
world.parachute = null
end
parachute_deployed = false
redef fun update(dt, world)
do
super
- if world.t - creation_time >= weapon.bullet_lifespan then destroy world
+ if world.t - creation_time >= weapon.bullet_lifespan then die world
end
# Hit `body`
fun hit_enemy(body: Body, world: World)
do
body.hit(self.weapon.damage, world)
- destroy world
+ die world
end
end
for i in planes.reverse_iterator do
if i.out_of_screen(p, self) then
#print "Despawning plane"
- i.destroy(self)
+ i.die(self)
end
end
if p == null then return
if p.altitude >= boss_altitude then
for e in enemies.reverse_iterator do if e isa JetpackEnemy then
- e.destroy(self)
+ e.die(self)
end
return
end
for i in enemies.reverse_iterator do
if i.out_of_screen(p, self) then
#print "Despawning enemy"
- i.destroy(self)
+ i.die(self)
end
end