- [NEW] afegit dimoni

This commit is contained in:
2026-04-13 12:01:22 +02:00
parent 90f66a4cdc
commit 44398f3080
8 changed files with 65 additions and 1 deletions

View File

@@ -240,4 +240,13 @@ animations = {
{ frame={x=32,y=0,w=16,h=18}, offset={flipped={x=0,y=-2}}, wait=2 }
}
},
["dimoni_walk"] = {
cycle = {1,2,1,3},
loop = true,
frames = {
{ frame={x=0,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 },
{ frame={x=16,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 },
{ frame={x=32,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 }
}
},
}

View File

@@ -9,7 +9,13 @@ function ia.update_bullet(spr)
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
if v.state == templates.ALIVE then
if v.bulletproof then
gota_esguita(spr)
else
v.state = templates.DYING
end
end
sprites.remove(spr)
return
end

View File

@@ -0,0 +1,31 @@
function ia.update_dimoni(spr)
map.surf(rooms.surf_foreground)
if spr.state == templates.ALIVE then
if sprites.hero.state == templates.ALIVE then
local x1,y1,w1,h1 = util.aabb(spr) -- El meu aabb
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
-- Si toca al heroi...
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
sprites.hero.hit()
spr.flipped = not spr.flipped
end
end
if spr.flipped then
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then
spr.pos.x = spr.pos.x - 1
else
spr.flipped = not spr.flipped
end
else
local tx, ty = (spr.pos.x+12)>>3, (spr.pos.y+15)>>3
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then
spr.pos.x = spr.pos.x + 1
else
spr.flipped = not spr.flipped
end
end
end
end

View File

@@ -19,4 +19,5 @@ items = {
{ name="gota", label="gota", visual={x=80, y=56, w=8, h=8} },
{ name="berserk", label="berserk", visual={x=16, y=24, w=16, h=16} },
{ name="abad", label="abad", visual={x=16, y=0, w=16, h=16} },
{ name="dimoni", label="dimoni", visual={x=32, y=0, w=16, h=17} },
}

View File

@@ -278,6 +278,23 @@ function me.create(type, options)
room = options.room,
ia = ia.update_coin
}
elseif key == "dimoni" then
sprite = {
type = key,
pos = options.pos,--{ x=100, y=4*12*8+71 },
size = { w=16,h=17 },
bbo = { left=3, top=2, right=3, bottom=0 },
current_frame = 1,
current_wait = 1,
flipped = options.flipped,
surf = surf.load("gfx/dimoni.gif"),
animation = "dimoni_walk",
state = me.ALIVE,
enemy = true,
bulletproof = true,
room = options.room,
ia = ia.update_dimoni
}
else
error("Template not recognized")
end