Implement death animation, but it currently loops constantly after the player dies...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 25 Nov 2012 10:52:53 +0000 (12:52 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 25 Nov 2012 19:02:01 +0000 (21:02 +0200)
mods/default/player.lua

index 4868c1f971255dd4de278c3ab060e9608db5c9c1..25c2532a7529806e4914f7703bc0d539485c839f 100644 (file)
@@ -72,7 +72,7 @@ function on_step(dtime)
                end
 
                local animation_speed_modified = animation_speed
-               if controls.sneak and (walking or controls.LMB) then
+               if controls.sneak and pl:get_hp() ~= 0 and (walking or controls.LMB) then
                        animation_speed_modified = animation_speed_modified / 2
                        -- Refresh player animation below
                        if not player_sneak[name] then
@@ -87,7 +87,13 @@ function on_step(dtime)
                        end
                end
 
-               if walking and controls.LMB then
+               if pl:get_hp() == 0 then
+                       if player_anim[name] ~= ANIM_DEATH then
+                               -- TODO: The death animation currently loops, we must make it play only once then stay at the last frame somehow
+                               pl:set_animation({x=anim.death_START, y=anim.death_END}, animation_speed_modified, animation_blend)
+                               player_anim[name] = ANIM_DEATH
+                       end
+               elseif walking and controls.LMB then
                        if player_anim[name] ~= ANIM_WALK_MINE then
                                pl:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_modified, animation_blend)
                                player_anim[name] = ANIM_WALK_MINE