action_nitro: bug fix
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 10 Mar 2017 14:50:24 +0000 (09:50 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 23 Mar 2017 23:33:00 +0000 (19:33 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/action_nitro/src/action_nitro.nit
contrib/action_nitro/src/game/core.nit
contrib/action_nitro/src/game/planegen.nit

index f6da14e..934cd94 100644 (file)
@@ -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)
index dc9a13b..9e437a1 100644 (file)
@@ -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
 
index 58c5410..94cb237 100644 (file)
@@ -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