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

@@ -21,7 +21,7 @@ local res_h = arcade_config.resolucion.height
local view_tile_id = false
local view_checking_tile = false
viewp = viewport.new()
viewp = viewport.new(arcade_config.resolucion.width, arcade_config.resolucion.height)
viewp:position(0,0)
actors={}
@@ -74,7 +74,7 @@ function game_init(menu)
table.insert( actors, zombie.new(68, 3, 3,false) )
table.insert( actors, zombie.new(73, 3, 3,false) )
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
-- local abad_x, abad_y = arc_mapa_get_coords ( 77, 3, 2 )
abad:move(abad_x, abad_y)
abad_make_safe( true )
@@ -140,14 +140,12 @@ function update_game()
-- if vp_y+1<=(tile_h*mapa_room_rows*mapa_pisos)-(res_h) then vp_y = vp_y+1 end
--end
load_tilemap( sf_mapa )
if key.press(key.N1) then
local hab = abad.hab-1
if hab<0 then hab=0 end
local hab_x = 4
local hab_y = 3
local abad_x, abad_y = arc_mapa_get_coords ( hab, hab_x, hab_y)
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
abad:move(abad_x, abad_y)
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
end
@@ -156,16 +154,19 @@ function update_game()
if hab<0 then hab=0 end
local hab_x = 4
local hab_y = 3
local abad_x, abad_y = arc_mapa_get_coords ( hab, hab_x, hab_y)
local abad_x, abad_y = coords.room_to_world ( hab, hab_x, hab_y)
abad:move(abad_x, abad_y)
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
end
if key.press(key.N0) then
local abad_x, abad_y = arc_mapa_get_coords ( 24, 1, 3 )
local abad_x, abad_y = coords.room_to_world ( 24, 1, 3 )
print(abad_x..", "..abad_y)
abad:move(abad_x, abad_y)
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
end
arc_mapa_update()
for key,actor in pairs(actors) do
actor:update()
--if actor.hab==cacau.hab and actor~=abad then
@@ -208,7 +209,7 @@ function update_game()
viewp:print()
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
local hab, xx, yy = arc_mapa_get_map_coords(abad.x, abad.y)
local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
-- msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true)
msg_print(0,42," JH= "..abad.jump_height,true)
@@ -271,7 +272,7 @@ end
function write_tile(x, y, yplus, print_type, align )
local scr_x, scr_y = viewp:screen_coords(x, y)
local hab, xx, yy = arc_mapa_get_map_coords(x, y)
local hab, xx, yy = coords.world_to_tile(x, y)
yplus = yplus or 0
print_type = print_type or false
@@ -283,7 +284,8 @@ function write_tile(x, y, yplus, print_type, align )
end
draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16)
local msg = mapa_get_tile(hab,xx,yy)
-- 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