- [NEW] Batman ja dispara batarangs

This commit is contained in:
2025-11-07 18:16:25 +01:00
parent 40342b858e
commit 8aa6631a8a
4 changed files with 66 additions and 1 deletions

39
data/batarang.lua Normal file
View File

@@ -0,0 +1,39 @@
require "mapa"
batarang = {
items = {},
cooldown = 0,
dx = 8,
draw = function()
surf.source(batman.surface)
for i, k in pairs(batarang.items) do
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
draw.surf(123,27,5,5,k.x,k.y,5,5, flip_h, flip_v)
end
end,
update = function()
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
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
--end
end,
}