- [NEW] Sucubo acabat i funcionant
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -167,7 +167,7 @@ animations = {
|
|||||||
},
|
},
|
||||||
["sucubo_stand"] = {
|
["sucubo_stand"] = {
|
||||||
cycle = {1},
|
cycle = {1},
|
||||||
loop = false,
|
loop = true,
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=0,y=0,w=16,h=16}, wait=100 },
|
{ frame={x=0,y=0,w=16,h=16}, wait=100 },
|
||||||
}
|
}
|
||||||
@@ -176,8 +176,15 @@ animations = {
|
|||||||
cycle = {1,2},
|
cycle = {1,2},
|
||||||
loop = false,
|
loop = false,
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=16,y=0,w=22,h=16}, offset={normal={x=-6,y=0}}, wait=2 },
|
{ frame={x=16,y=0,w=22,h=16}, offset={normal={x=-6,y=0}}, wait=8 },
|
||||||
{ frame={x=38,y=0,w=15,h=16}, offset={normal={x=5,y=0}}, wait=4 },
|
{ frame={x=38,y=0,w=15,h=16}, offset={normal={x=5,y=0},flipped={x=-4,y=0}}, wait=16 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["palo"] = {
|
||||||
|
cycle = {1},
|
||||||
|
loop = false,
|
||||||
|
frames = {
|
||||||
|
{ frame={x=0,y=9,w=16,h=6}, wait=100 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
24
data/modules/ia/palo.lua
Normal file
24
data/modules/ia/palo.lua
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
function ia.update_palo(spr)
|
||||||
|
local tx, ty, ty2 = (spr.pos.x+2)>>3, (spr.pos.y+1)>>3, (spr.pos.y+2)>>3
|
||||||
|
|
||||||
|
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||||
|
|
||||||
|
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()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
spr.dy = spr.dy + spr.ay;
|
||||||
|
spr.pos.y = spr.pos.y + spr.dy
|
||||||
|
if spr.flipped then
|
||||||
|
spr.pos.x = spr.pos.x - 6
|
||||||
|
else
|
||||||
|
spr.pos.x = spr.pos.x + 6
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@@ -1,7 +1,23 @@
|
|||||||
|
|
||||||
function ia.update_sucubo(spr)
|
function ia.update_sucubo(spr)
|
||||||
|
|
||||||
map.surf(rooms.surf_foreground)
|
map.surf(rooms.surf_foreground)
|
||||||
|
|
||||||
if spr.state == templates.ALIVE then
|
if spr.state == templates.ALIVE then
|
||||||
|
spr.timer = spr.timer + 1
|
||||||
|
if spr.timer==100 then
|
||||||
|
sprites.set_animation(spr, "sucubo_fire")
|
||||||
|
elseif spr.timer > 100 then
|
||||||
|
if spr.current_frame == 2 then
|
||||||
|
spr.timer = 0
|
||||||
|
local palo = templates.create("palo", {pos={x=spr.pos.x, y=spr.pos.y}, flipped=spr.flipped})
|
||||||
|
table.insert(sprites.list, palo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if spr.animation_finished then
|
||||||
|
spr.animation_finished = nil
|
||||||
|
sprites.set_animation(spr, "sucubo_stand")
|
||||||
|
end
|
||||||
if sprites.hero.state == templates.ALIVE then
|
if sprites.hero.state == templates.ALIVE then
|
||||||
local x1,y1,w1,h1 = util.aabb(spr) -- El meu aabb
|
local x1,y1,w1,h1 = util.aabb(spr) -- El meu aabb
|
||||||
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
|
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
items = {
|
items = {
|
||||||
{ name="mummy", label="momia", visual={x=0, y=24, w=16, h=16} },
|
{ name="mummy", label="momia", visual={x=0, y=24, w=16, h=16} },
|
||||||
{ name="coin", label="moneda", visual={x=0, y=40, w=8, h=8} },
|
{ name="coin", label="moneda", visual={x=0, y=40, w=8, h=8} },
|
||||||
{ name="torxa", label="torxa", visual={x=0, y=48, w=8, h=16} },
|
{ name="torxa", label="torxa", visual={x=0, y=48, w=8, h=16} },
|
||||||
{ name="clau verda", label="clau", visual={x=16, y=48, w=16, h=8} },
|
{ name="clau verda", label="clau", visual={x=16, y=48, w=16, h=8} },
|
||||||
{ name="clau groga", label="clau", visual={x=16, y=56, w=16, h=8} },
|
{ name="clau groga", label="clau", visual={x=16, y=56, w=16, h=8} },
|
||||||
{ name="clau roja", label="clau", visual={x=32, y=48, w=16, h=8} },
|
{ name="clau roja", label="clau", visual={x=32, y=48, w=16, h=8} },
|
||||||
{ name="clau blava", label="clau", visual={x=32, y=56, w=16, h=8} },
|
{ name="clau blava", label="clau", visual={x=32, y=56, w=16, h=8} },
|
||||||
{ name="porta verda", label="porta", visual={x=48, y=48, w=8, h=16} },
|
{ name="porta verda", label="porta", visual={x=48, y=48, w=8, h=16} },
|
||||||
{ name="porta groga", label="porta", visual={x=56, y=48, w=8, h=16} },
|
{ name="porta groga", label="porta", visual={x=56, y=48, w=8, h=16} },
|
||||||
{ name="porta roja", label="porta", visual={x=64, y=48, w=8, h=16} },
|
{ name="porta roja", label="porta", visual={x=64, y=48, w=8, h=16} },
|
||||||
{ name="porta blava", label="porta", visual={x=72, y=48, w=8, h=16} },
|
{ name="porta blava", label="porta", visual={x=72, y=48, w=8, h=16} },
|
||||||
{ name="sucubo", label="sucubo", visual={x=0, y=64, w=16, h=16} },
|
{ name="sucubo 0", label="sucubo00", visual={x=0, y=64, w=16, h=16} },
|
||||||
|
{ name="sucubo 25", label="sucubo25", visual={x=0, y=64, w=16, h=16} },
|
||||||
|
{ name="sucubo 50", label="sucubo50", visual={x=0, y=64, w=16, h=16} },
|
||||||
|
{ name="sucubo 75", label="sucubo75", visual={x=0, y=64, w=16, h=16} },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,11 +138,26 @@ function me.create(type, options)
|
|||||||
surf = surf.load("gfx/sucubo.gif"),
|
surf = surf.load("gfx/sucubo.gif"),
|
||||||
animation = "sucubo_stand",
|
animation = "sucubo_stand",
|
||||||
state = me.ALIVE,
|
state = me.ALIVE,
|
||||||
timer = 0,
|
timer = tonumber(value),
|
||||||
enemy = true,
|
enemy = true,
|
||||||
room = options.room,
|
room = options.room,
|
||||||
ia = ia.update_sucubo
|
ia = ia.update_sucubo
|
||||||
}
|
}
|
||||||
|
elseif key == "palo" then
|
||||||
|
sprite = {
|
||||||
|
type = key,
|
||||||
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
|
size = { w=16,h=6 },
|
||||||
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
|
current_frame = 1,
|
||||||
|
current_wait = 1,
|
||||||
|
flipped = options.flipped,
|
||||||
|
surf = surf.load("gfx/misc.gif"),
|
||||||
|
animation = "palo",
|
||||||
|
dy = -4,
|
||||||
|
ay = 1,
|
||||||
|
ia = ia.update_palo
|
||||||
|
}
|
||||||
else
|
else
|
||||||
error("Template not recognized")
|
error("Template not recognized")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user