122 lines
3.1 KiB
Lua
122 lines
3.1 KiB
Lua
function arc_text(str, x, y, col)
|
|
font.current(font_sf)
|
|
draw.text(str,x,y,col)
|
|
end
|
|
|
|
function arc_textB(str, x, y, col)
|
|
font.current(font_sf)
|
|
-- Crear el borde negre
|
|
draw.text(str, x-1, y-1, 16)
|
|
draw.text(str, x , y-1, 16)
|
|
draw.text(str, x+1, y-1, 16)
|
|
|
|
draw.text(str, x-1, y, 16)
|
|
draw.text(str, x+1, y, 16)
|
|
|
|
draw.text(str, x-1, y+1, 16)
|
|
draw.text(str, x , y+1, 16)
|
|
draw.text(str, x+1, y+1, 16)
|
|
-- Escriure la cadena
|
|
draw.text(str,x,y,col)
|
|
end
|
|
|
|
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
|
|
local x = 0
|
|
local y = 0
|
|
local yroom = 0
|
|
local xroom = 0
|
|
|
|
map.surf(sf_mapa)
|
|
for ty=0,mapa_th-1 do
|
|
if y == mapa_room_rows then
|
|
yroom = yroom + mapa_rooms_per_piso
|
|
y = 0
|
|
end
|
|
xroom = yroom
|
|
for tx=0,mapa_tw-1 do
|
|
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
|
|
x = 0
|
|
xroom = xroom + 1
|
|
end
|
|
end
|
|
y = y +1
|
|
end
|
|
end
|
|
|
|
-- DEBUG
|
|
|
|
-- Imprime cualquier valor, incluyendo tablas anidadas
|
|
function dump(value, indent)
|
|
indent = indent or ""
|
|
if type(value) ~= "table" then
|
|
return tostring(value)
|
|
end
|
|
|
|
local parts = {"{"}
|
|
for k, v in pairs(value) do
|
|
local key = (type(k) == "string") and k or "["..tostring(k).."]"
|
|
table.insert(parts,
|
|
string.format("%s %s = %s,",
|
|
indent, key, dump(v, indent.." ")))
|
|
end
|
|
table.insert(parts, indent.."}")
|
|
return table.concat(parts, "\n")
|
|
end
|
|
|
|
function msg_print(x, y, msg, direct_print )
|
|
local scr_x, scr_y
|
|
direct_print = direct_print or false
|
|
if direct_print then
|
|
scr_x = x
|
|
scr_y = y
|
|
else
|
|
scr_x, scr_y = viewp:screen_coords(x, y)
|
|
end
|
|
draw.rectf(scr_x,scr_y,45,7,16)
|
|
draw.text(msg,scr_x+1,scr_y+1,2)
|
|
end
|
|
|
|
function view_coord(x, y, w, h, color)
|
|
local scr_x, scr_y = viewp:screen_coords(x, y)
|
|
draw.rect(scr_x, scr_y, w, h, color)
|
|
end
|
|
|
|
function debug.write_tile(x, y, yplus, print_type, align )
|
|
local scr_x, scr_y = viewp:screen_coords(x, y)
|
|
local hab, xx, yy = coords.world_to_tile(x, y)
|
|
|
|
yplus = yplus or 0
|
|
print_type = print_type or false
|
|
align = align or "R"
|
|
|
|
local txt_offset = -7
|
|
if align=="R" then txt_offset = -14
|
|
elseif align=="L" then txt_offset = 0
|
|
end
|
|
|
|
draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16)
|
|
-- local msg = mapa_get_tile(hab,xx,yy)
|
|
local msg = arc_get_tile(x,y)
|
|
if print_type then
|
|
msg = msg.." "..arc_check_tile(x, y)
|
|
end
|
|
draw.text(msg,scr_x+txt_offset+1,scr_y+1+yplus,2)
|
|
end
|