From 05254025ee298236bf5e952301345af85a805ef8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 10 Mar 2017 09:50:24 -0500 Subject: [PATCH] action_nitro: bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/action_nitro/src/action_nitro.nit | 2 +- contrib/action_nitro/src/game/core.nit | 15 +++++++++------ contrib/action_nitro/src/game/planegen.nit | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/contrib/action_nitro/src/action_nitro.nit b/contrib/action_nitro/src/action_nitro.nit index f6da14e..934cd94 100644 --- a/contrib/action_nitro/src/action_nitro.nit +++ b/contrib/action_nitro/src/action_nitro.nit @@ -201,7 +201,7 @@ redef class App # Prepare for intro animation ui_sprites.add tutorial_goal - world_camera.far = 700.0 + world_camera.far = 1024.0 end redef fun update(dt) diff --git a/contrib/action_nitro/src/game/core.nit b/contrib/action_nitro/src/game/core.nit index dc9a13b..9e437a1 100644 --- a/contrib/action_nitro/src/game/core.nit +++ b/contrib/action_nitro/src/game/core.nit @@ -227,17 +227,18 @@ abstract class Body 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 @@ -264,6 +265,7 @@ abstract class Platform redef fun die(world) do + if not is_alive then return super world.explode(center, width) world.score += 1 @@ -482,8 +484,9 @@ abstract class Human 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 @@ -721,14 +724,14 @@ abstract class Bullet 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 diff --git a/contrib/action_nitro/src/game/planegen.nit b/contrib/action_nitro/src/game/planegen.nit index 58c5410..94cb237 100644 --- a/contrib/action_nitro/src/game/planegen.nit +++ b/contrib/action_nitro/src/game/planegen.nit @@ -40,7 +40,7 @@ redef class World 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 @@ -118,14 +118,14 @@ redef class World 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 -- 1.7.9.5