-[NEW] Rata acabada
BIN
data/gfx/rata.gif
Normal file
|
After Width: | Height: | Size: 187 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -194,4 +194,14 @@ animations = {
|
|||||||
{ frame={x=0,y=0,w=16,h=16}, wait=100 }
|
{ frame={x=0,y=0,w=16,h=16}, wait=100 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
["rata"] = {
|
||||||
|
cycle = {1,2,3,4,2},
|
||||||
|
loop = true,
|
||||||
|
frames = {
|
||||||
|
{ frame={x=0,y=0,w=9,h=8}, wait=2 },
|
||||||
|
{ frame={x=9,y=0,w=9,h=8}, wait=2 },
|
||||||
|
{ frame={x=18,y=0,w=9,h=8}, wait=2 },
|
||||||
|
{ frame={x=27,y=0,w=9,h=8}, wait=2 }
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
28
data/modules/ia/rata.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
function ia.update_rata(spr)
|
||||||
|
map.surf(rooms.surf_foreground)
|
||||||
|
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
|
||||||
|
|
||||||
|
if spr.flipped then
|
||||||
|
local tx, ty = (spr.pos.x-1)>>3, (spr.pos.y+7)>>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+9)>>3, (spr.pos.y+7)>>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
|
||||||
@@ -15,4 +15,5 @@ items = {
|
|||||||
{ name="sucubo 50", label="sucubo50", 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} },
|
{ name="sucubo 75", label="sucubo75", visual={x=0, y=64, w=16, h=16} },
|
||||||
{ name="nemesio", label="nemesio", visual={x=16, y=80, w=16, h=16} },
|
{ 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} },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,22 @@ function me.create(type, options)
|
|||||||
room = options.room,
|
room = options.room,
|
||||||
ia = ia.update_nemesio
|
ia = ia.update_nemesio
|
||||||
}
|
}
|
||||||
|
elseif key == "rata" then
|
||||||
|
sprite = {
|
||||||
|
type = key,
|
||||||
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
|
size = { w=9,h=8 },
|
||||||
|
bbo = { left=0, top=5, right=0, bottom=0 },
|
||||||
|
current_frame = 1,
|
||||||
|
current_wait = 1,
|
||||||
|
flipped = options.flipped,
|
||||||
|
surf = surf.load("gfx/rata.gif"),
|
||||||
|
animation = "rata",
|
||||||
|
state = me.ALIVE,
|
||||||
|
enemy = true,
|
||||||
|
room = options.room,
|
||||||
|
ia = ia.update_rata
|
||||||
|
}
|
||||||
else
|
else
|
||||||
error("Template not recognized")
|
error("Template not recognized")
|
||||||
end
|
end
|
||||||
|
|||||||