- [NEW] Nous tiles - [NEW] Batman ja puja i baixa per cordes/cadenes - [NEW] El batarang es mes visible - [NEW] el ganxo es mes visible
49 lines
1.4 KiB
Lua
49 lines
1.4 KiB
Lua
require "mapa"
|
|
|
|
batarang = {
|
|
items = {},
|
|
cooldown = 0,
|
|
frame_time = 0.0,
|
|
dx = 160,
|
|
|
|
draw = function()
|
|
surf.source(batman.surface)
|
|
for i, k in pairs(batarang.items) do
|
|
k.blink = not k.blink
|
|
local flip_h, flip_v = false, false
|
|
if k.s==1 or k.s==2 then flip_v = true end
|
|
if k.s==2 or k.s==3 then flip_h = true end
|
|
if k.blink then pal.subpal(65,22) end
|
|
draw.surf(123,27,5,5,k.x,k.y,5,5, flip_h, flip_v)
|
|
if k.blink then pal.subpal(65) end
|
|
end
|
|
end,
|
|
|
|
update = function()
|
|
local d = sys.delta()
|
|
|
|
if batarang.cooldown > 0 then batarang.cooldown = batarang.cooldown - 1 end
|
|
for i, k in pairs(batarang.items) do
|
|
local tx, ty = ((k.x+2)//8), ((k.y+2)//8)
|
|
if (mapa.isSolid(tx,ty)) then
|
|
batarang.items[i] = nil
|
|
else
|
|
k.x = k.x + k.dx*d
|
|
batarang.frame_time = batarang.frame_time + d
|
|
if batarang.frame_time >= 0.06 then
|
|
batarang.frame_time = 0.0
|
|
k.s = k.s + 1
|
|
if (k.s==4) then k.s = 0 end
|
|
end
|
|
end
|
|
end
|
|
end,
|
|
|
|
new = function(x,y,flip)
|
|
--if batarang.cooldown == 0 then
|
|
table.insert(batarang.items, {x=x, y=y, s=0, dx=flip and -160 or 160, blink=false})
|
|
batarang.cooldown = 10
|
|
--end
|
|
end,
|
|
|
|
} |