[NEW] Afegida una capa al mapa per a fer coses especials

This commit is contained in:
2026-05-02 22:01:44 +02:00
parent a4f7d78457
commit 7eb8162621
4 changed files with 74 additions and 20 deletions

41
data/tiles_layer2.lua Normal file
View File

@@ -0,0 +1,41 @@
tiles_layer2={
surf = nil,
tiles = {},
}
function tiles_layer2.new(_hab, _x, _y, _tx, _ty, _tw, _th)
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
print(world_x.." "..world_y)
table.insert(
tiles_layer2.tiles,
{ hab = _hab,
x = world_x,
y = world_y,
w = _tw,
h = _th,
tx = _tx,
ty = _ty,
tw = _tw,
th = _th,
}
)
end
function tiles_layer2.draw()
for i, tile in ipairs(tiles_layer2.tiles) do
if viewp:inside(tile.x, tile.y, tile.w, tile.h) then
local curr_surf = surf.source()
if tiles_layer2.surf ~= nil then
surf.source(tiles_layer2.surf)
end
local scr_x, scr_y = viewp:screen_coords( tile.x, tile.y )
draw.surf(tile.tx, tile.ty, tile.tw, tile.th,
scr_x, scr_y, tile.tw, tile.th)
surf.source(curr_surf)
end
end
end
function tiles_layer2.update()
end