- [NEW] Passat a delta time
- [NEW] Nous tiles - [NEW] Batman ja puja i baixa per cordes/cadenes - [NEW] El batarang es mes visible - [NEW] el ganxo es mes visible
This commit is contained in:
@@ -3,36 +3,46 @@ require "mapa"
|
||||
batarang = {
|
||||
items = {},
|
||||
cooldown = 0,
|
||||
dx = 8,
|
||||
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
|
||||
k.s = k.s + 1
|
||||
if (k.s==4) then k.s = 0 end
|
||||
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 -8 or 8})
|
||||
-- batarang.cooldown = 5
|
||||
table.insert(batarang.items, {x=x, y=y, s=0, dx=flip and -160 or 160, blink=false})
|
||||
batarang.cooldown = 10
|
||||
--end
|
||||
end,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user