aboutsummaryrefslogtreecommitdiff
path: root/lua/pets/animations.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/pets/animations.lua')
-rw-r--r--lua/pets/animations.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua
index 960230f..fad62e8 100644
--- a/lua/pets/animations.lua
+++ b/lua/pets/animations.lua
@@ -28,6 +28,7 @@ function M.Animation.new(sourcedir, type, style, popup, user_opts)
instance.actions = listdir(sourcedir)
instance.frames = {}
instance.popup = popup
+ instance.diying = false
-- user options
instance.row, instance.col = user_opts.row, user_opts.col
@@ -82,6 +83,10 @@ function M.Animation:next_frame()
end
if self.frame_counter > #self.frames[self.current_action] then -- true every 8 frames
M.Animation.set_next_action(self)
+ if self.dead then
+ self.timer = nil
+ return
+ end
self.frame_counter = 1
end
-- frames contains the images for every action
@@ -93,6 +98,15 @@ end
-- @function decide which action comes after the following
function M.Animation:set_next_action()
+ if self.dying then
+ if self.current_action == "die" then
+ self.dead = true
+ M.Animation.stop(self)
+ self.popup:unmount()
+ end
+ self.current_action = "die"
+ return
+ end
local next_actions = {
crouch = { "liedown", "sneak", "sit" },
idle = { "idle_blink", "walk", "sit" },