Factoritzades funcions per a conversió de coordenades.

[NEW] Tiles animats
This commit is contained in:
2026-03-28 21:08:45 +01:00
parent 639d2e98ad
commit ac9fcebca9
15 changed files with 393 additions and 201 deletions

View File

@@ -18,10 +18,10 @@ switches={
function switches.start(x, y)
if switches.cooldown>0 then return end
local hab, hx, hy = arc_mapa_get_map_coords(x, y)
local hab, hx, hy = coords.world_to_tile(x, y)
local tile_idx = (hx+hy*mapa_room_cols)+1
print("Switch > "..x..", "..y.." / "..hab..", "..hx..", "..hy.." T="..tile_idx)
mapa_set_tile_by_index(hab,tile_idx,57)
-- mapa_set_tile_by_index(hab,tile_idx,57)
arc_set_tile(x, y, editor_to_map_tile(57))
switches.current_list=switches[hab+1][tile_idx]
switches.current_index=2
switches.wait=0
@@ -38,7 +38,17 @@ function switches.update()
if switches.wait>=6 then
switches.wait=0
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
local hab= switches.current_list[1]-1
local tile_idx= switches.current_list[switches.current_index]+1
-- print(hab.." ("..tile_x..", "..tile_y..")")
-- local tile_x, tile_y = coords.room_index_to_xy ( hab, tile_idx )
-- local world_x, world_y = coords.room_to_world(hab, tile_x, tile_y)
-- arc_set_tile(world_x, world_y, 256)
arc_set_tile_by_index(hab,tile_idx,mapa_empty_tile)
-- mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
switches.current_index=switches.current_index+1
if switches.current_index>#switches.current_list then
switches.current_list=nil