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

@@ -1,4 +1,5 @@
arcade_config = require("arcade_config")
coords = require "coords"
require "fps"
require "fade"
@@ -11,6 +12,26 @@ require "game"
require "switches"
-- require "scenes"
coords.set_config({
tiles_width = arcade_config.tiles_width,
tiles_height = arcade_config.tiles_height,
room_cols = mapa_room_cols,
room_rows = mapa_room_rows,
rooms_per_floor = mapa_rooms_per_piso,
})
function editor_to_map_tile(editor_tile)
local result = 0
if editor_tile<256 then result = editor_tile + arcade_config.tiles_offset end
return result
end
function map_to_editor_tile(map_tile)
local result = map_tile - arcade_config.tiles_offset
if map_tile==0 then result = 256 end
return result
end
function load_tilemap( sf_mapa )
local mapa_tw, mapa_th = surf.size(sf_mapa)
local nrooms = mapa_rooms_per_piso*mapa_pisos
@@ -27,8 +48,7 @@ function load_tilemap( sf_mapa )
end
xroom = yroom
for tx=0,mapa_tw-1 do
local tile=mapa[1+xroom][1+x+y*mapa_room_cols]
if tile<128 then tile= tile + 128 end
local tile=editor_to_map_tile(mapa[1+xroom][1+x+y*mapa_room_cols])
map.tile(tx, ty, tile)
x = x + 1
if x == mapa_room_cols then
@@ -91,9 +111,9 @@ function mini.init()
btnCycle2 = tonumber(config.key("btncycle2")) or pad.LEFTSHOULDER
btnPause = tonumber(config.key("btnpause")) or pad.START
-- game_init()
-- logo_init()
-- intro_init()
logo_init()
game_init()
-- final_init()
end
@@ -158,35 +178,3 @@ function arc_textB(str, x, y, col, colB)
draw.surf(0,0,sw,sh,x,y,dw,dh)
surf.source(curr_surf_src)
end
function arc_textB2(str, x, y, col, colB)
local ox, oy = view.origin()
local curr_surf_tgt = surf.target()
local curr_surf_src = surf.source()
local sw = arcade_config.org_resolucion.width
local sh = arcade_config.org_resolucion.height
local dw = arcade_config.resolucion.width
local dh = arcade_config.resolucion.height
colB = colB or 16
surf.target(textsf)
view.origin(0,0)
surf.cls(0)
draw.text(str,0,0,colB)
draw.text(str,1,0,colB)
draw.text(str,2,0,colB)
draw.text(str,0,1,colB)
draw.text(str,2,1,colB)
draw.text(str,0,2,colB)
draw.text(str,1,2,colB)
draw.text(str,2,2,colB)
draw.text(str,1,1,col)
-- print("arc_B "..str)
surf.source(textsf)
surf.target(curr_surf_tgt)
view.origin(ox,oy)
-- draw.surf(0,0,sw,sh,x,y,dw,dh)
draw.surf(0,0)
surf.source(curr_surf_src)
end