From ee951a96308e961f3202b800e28a6c4efc2c50bf Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 27 Jun 2025 06:27:34 +0200 Subject: [PATCH] - [FIX] Ja no peta al morir una momia --- data/animations.lua | 2 +- data/sprites.lua | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/data/animations.lua b/data/animations.lua index dc507ad..2440f2a 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -70,7 +70,7 @@ animations = { ["mummy_dead"] = { cycle = {1}, frames = { - { frame={x=128,y=24,w=16,h=17}, wait=4 }, + { frame={x=128,y=24,w=16,h=17}, wait=50 }, } }, } \ No newline at end of file diff --git a/data/sprites.lua b/data/sprites.lua index 8235e09..27c7cb0 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -108,16 +108,24 @@ sprites = { end elseif spr.state == templates.DYING then if spr.animation ~= "mummy_dying" then - spr.animation = "mummy_dying" + sprites.set_animation(spr, "mummy_dying") + --spr.animation = "mummy_dying" + --spr.current_frame = 1 else if spr.current_frame == 8 then - spr.animation = "mummy_dead" + sprites.set_animation(spr, "mummy_dead") + --spr.animation = "mummy_dead" + --spr.current_frame = 1 spr.state = templates.DEAD print("DEAD") -- [TOFIX] end end elseif spr.state == templates.DEAD then -- [TODO] + if spr.current_wait == 1 then + sprites.set_animation(spr, "mummy_walk") + spr.state = templates.ALIVE + end end end, @@ -128,7 +136,7 @@ sprites = { local x1,y1,w1,h1 = util.aabb(spr) for i,v in ipairs(sprites.list) do - if v.enemy then + if v.enemy and v.state ~= templates.DEAD then local x2,y2,w2,h2 = util.aabb(v) if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then if v.state == templates.ALIVE then v.state = templates.DYING end @@ -291,6 +299,9 @@ sprites = { draw_sprite = function(sprite) local cycle = animations[sprite.animation].cycle[sprite.current_frame] local frame = animations[sprite.animation].frames[cycle] + if not frame then + print(sprite.current_frame) + end local reversed = frame.reversed or false draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped)) local x,y,w,h = util.aabb(sprite)