-[NEW] Nemesio acabat

This commit is contained in:
2026-03-22 09:51:41 +01:00
parent c4da64aa1f
commit c02c086af3
4 changed files with 37 additions and 11 deletions

View File

@@ -1,16 +1,29 @@
require ":utils.util"
nemesio = { STATIC = 1, FLOATING = 2 }
function ia.update_nemesio(spr)
spr.timer = spr.timer + 1
if spr.state == templates.ALIVE then
local target = {x=sprites.hero.pos.x-spr.pos.x, y=sprites.hero.pos.y-spr.pos.y}
if target.x > 0 then
spr.flipped = false
else
spr.flipped = true
end
if spr.substate == nemesio.STATIC then
spr.mode = draw.NORMAL
if spr.timer==100 then
spr.timer=0
spr.state = templates.DYING
local target = {x=sprites.hero.pos.x-spr.pos.x, y=sprites.hero.pos.y-spr.pos.y}
spr.advance = util.normalize(target)
spr.fpos = {x=spr.pos.x, y=spr.pos.y}
spr.substate = nemesio.FLOATING
spr.advance = {x=0,y=0}
if math.abs(target.x) > math.abs(target.y) then
spr.advance.x = math.sign(target.x)
else
spr.advance.y = math.sign(target.y)
end
end
if sprites.hero.state == templates.ALIVE then
@@ -22,14 +35,14 @@ function ia.update_nemesio(spr)
end
end
elseif spr.state == templates.DYING then
spr.fpos.x = spr.fpos.x + spr.advance.x
spr.fpos.y = spr.fpos.y + spr.advance.y
spr.pos.x = math.floor(spr.fpos.x)
spr.pos.y = math.floor(spr.fpos.y)
elseif spr.substate == nemesio.FLOATING then
spr.mode = draw.PATTERN
spr.pattern = 0xa5a5
spr.pos.x = spr.pos.x + spr.advance.x
spr.pos.y = spr.pos.y + spr.advance.y
if spr.timer == 32 then
spr.timer = 0
spr.state = templates.ALIVE
spr.substate = nemesio.STATIC
end
end
end