[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

View File

@@ -25,8 +25,9 @@ require "trigger_event"
require "batman" require "batman"
require "health_potion" require "health_potion"
require "tiles_layer2"
local DEBUG = false local DEBUG = true
local tile_w = arcade_config.tiles_width local tile_w = arcade_config.tiles_width
local tile_h = arcade_config.tiles_height local tile_h = arcade_config.tiles_height
@@ -187,6 +188,7 @@ end
function world_update() function world_update()
-- Actualitzar moviment del mapa (ex: tiles animats) -- Actualitzar moviment del mapa (ex: tiles animats)
arc_mapa_update() arc_mapa_update()
tiles_layer2.update()
-- Moure a tots -- Moure a tots
for key,actor in pairs(actors) do for key,actor in pairs(actors) do
@@ -227,6 +229,7 @@ end
function world_draw() function world_draw()
-- Pintar la finestra del mon -- Pintar la finestra del mon
render_map(sf_mapa, tiles, viewp.x, viewp.y) render_map(sf_mapa, tiles, viewp.x, viewp.y)
tiles_layer2.draw()
if stages.boss_loaded then stage_draw_back() end if stages.boss_loaded then stage_draw_back() end

View File

@@ -91,8 +91,11 @@ function stages.stage1_init()
table.insert( actors, zombie.new(73, 7, 3,false) ) table.insert( actors, zombie.new(73, 7, 3,false) )
table.insert( actors, zombie.new(75, 3, 3,true) ) table.insert( actors, zombie.new(75, 3, 3,true) )
local hp_x, hp_y = coords.room_to_world(11, 7, 4) local hp_x, hp_y = coords.room_to_world(14, 10, 4)
table.insert( actors, health_potion.new(11, hp_x, hp_y, 0, 0, 1) ) table.insert( actors, health_potion.new(14, hp_x, hp_y, 0, 0, 2) )
local hp_x, hp_y = coords.room_to_world(77, 7, 4)
table.insert( actors, health_potion.new(77, hp_x, hp_y, 0, 0, 3) )
-- TRIGGERS -- TRIGGERS
-- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end -- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end
@@ -149,6 +152,10 @@ function stages.stage1_init()
nil, nil,
elalien, abad, 150, "I les tisores de podar?", 250) elalien, abad, 150, "I les tisores de podar?", 250)
tiles_layer2.new(13,11,3,144,144,16,16)
tiles_layer2.new(13,11,4,144,144,16,16)
tiles_layer2.new(11,10,2,128,208,16,16)
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 ) local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 ) -- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
-- local abad_x, abad_y = coords.room_to_world ( 18, 9, 3 ) -- local abad_x, abad_y = coords.room_to_world ( 18, 9, 3 )
@@ -347,33 +354,36 @@ stage1_mapa={
-- 12 -- 12
{ {
-- 28,29,28,29,28,29,29,256,256,256,26,27, -- 28,29,28,29,28,29,29,256,256,256,26,27,
28,29,28,29,28,29,29,1,256,256,26,27, 28, 29, 28, 29, 28, 29, 29, 1,256,256, 26, 27,
256,256,256,256,256,256,256,256,256,25,72,256, 256,256,256,256,256,256,256,256,256, 25, 72,256,
256,256,73,74,256,256,256,256,1,256,88,256, -- 256,256, 73, 74,256,256,256,256, 1,256, 88,256,
256,256,89,90,256,256,256,1,256,256,256,256, 256,256, 73, 74,256,256,256,256, 1,256,256,256,
256,256,256,256,256,256,1,256,256,256,256,256, 256,256, 89, 90,256,256,256, 1,256,256,256,256,
28,29,28,29,28,29,28,29,28,29,28,29, 256,256,256,256,256,256, 1,256,256,256,256,256,
28, 29, 28, 29, 28, 29, 28, 29, 28, 29, 28, 29,
}, },
-- 13 -- 13
{ {
28,29,26,27,26,27,28,29,28,29,28,29, 28, 29, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29,
256,256,256,26,27,256,256,256,256,256,256,256, 256,256,256, 26, 27,256,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,73,74,256,256, 256,256,256,256,256,256,256,256, 73, 74,256,256,
256,256,256,98,98,256,256,256,89,90,256,256, 256,256,256, 98, 98,256,256,256, 89, 90,256,256,
256,256,104,101,102,103,256,256,256,256,256,256, 256,256,104,101,102,103,256,256,256,256,256,256,
-- 28,29,28,29,28,29,29,256,81,25,28,29, -- 28,29,28,29,28,29,29,256,81,25,28,29,
28,29,28,29,28,29,29,256,256,1,28,29, 28, 29, 28, 29, 28, 29, 29,256,256, 1, 28, 29,
}, },
-- 14 -- 14
{ {
28,29,28,29,28,29,28,29,10,11,28,25, 28, 29, 28, 29, 28, 29, 28, 29, 10, 11, 28, 25,
256,256,256,256,256,256,256,256,10,11,256,25, 256,256,256,256,256,256,256,256, 10, 11,256, 25,
256,73,74,256,256,256,256,256,10,11,256,256, -- 256, 73, 74,256,256,256,256,256, 10, 11,256,256,
256,89,90,256,256,75,76,256,10,11,256,25, 256, 73, 74,256,256,256,256,256, 10, 11,256, 25,
256,256,256,256,256,91,92,256,10,11,256,25, 256, 89, 90,256,256, 75, 76,256, 10, 11,256,256,
28,29,28,29,28,29,28,29,28,29,28,29, -- 256,256,256,256,256, 91, 92,256, 10, 11,256, 25,
256,256,256,256,256, 91, 92,256, 10, 11,256,256,
28, 29, 28, 29, 28, 29, 28, 29, 28, 29, 28, 29,
}, },
-- 15 -- 15

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

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