- [NEW] afegit dimoni
This commit is contained in:
BIN
data/gfx/dimoni.gif
Normal file
BIN
data/gfx/dimoni.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 371 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
@@ -240,4 +240,13 @@ animations = {
|
|||||||
{ frame={x=32,y=0,w=16,h=18}, offset={flipped={x=0,y=-2}}, wait=2 }
|
{ 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 }
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,13 @@ function ia.update_bullet(spr)
|
|||||||
if v.enemy and v.state ~= templates.DEAD then
|
if v.enemy and v.state ~= templates.DEAD then
|
||||||
local x2,y2,w2,h2 = util.aabb(v)
|
local x2,y2,w2,h2 = util.aabb(v)
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
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)
|
sprites.remove(spr)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
31
data/modules/ia/dimoni.lua
Normal file
31
data/modules/ia/dimoni.lua
Normal 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
|
||||||
@@ -19,4 +19,5 @@ items = {
|
|||||||
{ name="gota", label="gota", visual={x=80, y=56, w=8, h=8} },
|
{ 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="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="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} },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,6 +278,23 @@ function me.create(type, options)
|
|||||||
room = options.room,
|
room = options.room,
|
||||||
ia = ia.update_coin
|
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
|
else
|
||||||
error("Template not recognized")
|
error("Template not recognized")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user