- [NEW] Berserk implementat
- [NEW] Millorats detalls en habitacions - [NEW] Habitacions al 44%
BIN
data/gfx/berserk.gif
Normal file
|
After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
58
data/modules/ia/berserk.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
function ia.update_berserk(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
|
||||
|
||||
local advance = 1
|
||||
if sprites.hero.pos.y == spr.pos.y-1 then advance = 2 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 - advance
|
||||
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 + advance
|
||||
else
|
||||
spr.flipped = not spr.flipped
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elseif spr.state == templates.DYING then
|
||||
if spr.animation ~= "mummy_dying" then
|
||||
sprites.set_animation(spr, "mummy_dying")
|
||||
spr.surf = surf.load("gfx/mummy.gif")
|
||||
else
|
||||
if spr.current_frame == 8 then
|
||||
sprites.set_animation(spr, "mummy_dead")
|
||||
spr.state = templates.DEAD
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elseif spr.state == templates.DEAD then
|
||||
if spr.current_wait == 1 then
|
||||
sprites.set_animation(spr, "mummy_undying")
|
||||
spr.state = templates.RESURRECTING
|
||||
end
|
||||
elseif spr.state == templates.RESURRECTING then
|
||||
if spr.current_frame == 13 then
|
||||
sprites.set_animation(spr, "mummy_walk")
|
||||
spr.surf = surf.load("gfx/berserk.gif")
|
||||
spr.state = templates.ALIVE
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -17,4 +17,5 @@ items = {
|
||||
{ name="nemesio", label="nemesio", visual={x=16, y=80, w=16, h=16} },
|
||||
{ name="rata", label="rata", visual={x=80, y=48, w=9, 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} },
|
||||
}
|
||||
|
||||
@@ -246,6 +246,22 @@ function me.create(type, options)
|
||||
room = options.room,
|
||||
ia = ia.update_gota_esguit
|
||||
}
|
||||
elseif key == "berserk" then
|
||||
sprite = {
|
||||
type = key,
|
||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||
size = { w=16,h=16 },
|
||||
bbo = { left=3, top=2, right=3, bottom=0 },
|
||||
current_frame = 1,
|
||||
current_wait = 1,
|
||||
flipped = options.flipped,
|
||||
surf = surf.load("gfx/berserk.gif"),
|
||||
animation = "mummy_walk",
|
||||
state = me.ALIVE,
|
||||
enemy = true,
|
||||
room = options.room,
|
||||
ia = ia.update_berserk
|
||||
}
|
||||
else
|
||||
error("Template not recognized")
|
||||
end
|
||||
|
||||