-[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

View File

@@ -185,7 +185,11 @@ function sprites.draw_sprite(sprite)
local reversed = frame.reversed or false
if not sprite.invisible then
surf.source(sprite.surf)
if sprite.pattern then draw.pattern(sprite.pattern) end
if sprite.mode then draw.mode(sprite.mode) end
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x+ox, sprite.pos.y+oy, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped))
draw.pattern(0xffff)
draw.mode(draw.NORMAL)
end
if cheats.showaabb then
local x,y,w,h = util.aabb(sprite)

View File

@@ -170,6 +170,7 @@ function me.create(type, options)
surf = surf.load("gfx/nemesio.gif"),
animation = "nemesio",
state = me.ALIVE,
substate = nemesio.STATIC,
timer = 0,
enemy = true,
room = options.room,