diff --git a/data/game.lua b/data/game.lua index 1d3ba2f..fd7046e 100644 --- a/data/game.lua +++ b/data/game.lua @@ -25,8 +25,9 @@ require "trigger_event" require "batman" require "health_potion" +require "tiles_layer2" -local DEBUG = false +local DEBUG = true local tile_w = arcade_config.tiles_width local tile_h = arcade_config.tiles_height @@ -187,6 +188,7 @@ end function world_update() -- Actualitzar moviment del mapa (ex: tiles animats) arc_mapa_update() + tiles_layer2.update() -- Moure a tots for key,actor in pairs(actors) do @@ -227,6 +229,7 @@ end function world_draw() -- Pintar la finestra del mon render_map(sf_mapa, tiles, viewp.x, viewp.y) + tiles_layer2.draw() if stages.boss_loaded then stage_draw_back() end diff --git a/data/stage1.lua b/data/stage1.lua index 9038cfe..49bb740 100644 --- a/data/stage1.lua +++ b/data/stage1.lua @@ -91,8 +91,11 @@ function stages.stage1_init() table.insert( actors, zombie.new(73, 7, 3,false) ) table.insert( actors, zombie.new(75, 3, 3,true) ) - local hp_x, hp_y = coords.room_to_world(11, 7, 4) - table.insert( actors, health_potion.new(11, hp_x, hp_y, 0, 0, 1) ) + local hp_x, hp_y = coords.room_to_world(14, 10, 4) + 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 -- 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, 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 ( 54, 8, 3 ) -- local abad_x, abad_y = coords.room_to_world ( 18, 9, 3 ) @@ -347,33 +354,36 @@ stage1_mapa={ -- 12 { -- 28,29,28,29,28,29,29,256,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,73,74,256,256,256,256,1,256,88,256, - 256,256,89,90,256,256,256,1,256,256,256,256, - 256,256,256,256,256,256,1,256,256,256,256,256, - 28,29,28,29,28,29,28,29,28,29,28,29, + 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, 73, 74,256,256,256,256, 1,256, 88,256, + 256,256, 73, 74,256,256,256,256, 1,256,256,256, + 256,256, 89, 90,256,256,256, 1,256,256,256,256, + 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 { - 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,256,256,256,256,256,73,74,256,256, - 256,256,256,98,98,256,256,256,89,90,256,256, + 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,256,256,256,256,256, 73, 74,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, -- 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 { - 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,73,74,256,256,256,256,256,10,11,256,256, - 256,89,90,256,256,75,76,256,10,11,256,25, - 256,256,256,256,256,91,92,256,10,11,256,25, - 28,29,28,29,28,29,28,29,28,29,28,29, + 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, 73, 74,256,256,256,256,256, 10, 11,256,256, + 256, 73, 74,256,256,256,256,256, 10, 11,256, 25, + 256, 89, 90,256,256, 75, 76,256, 10, 11,256,256, + -- 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 diff --git a/data/tiles.gif b/data/tiles.gif index 798ce18..e0aceb7 100644 Binary files a/data/tiles.gif and b/data/tiles.gif differ diff --git a/data/tiles_layer2.lua b/data/tiles_layer2.lua new file mode 100644 index 0000000..b5dab03 --- /dev/null +++ b/data/tiles_layer2.lua @@ -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 \ No newline at end of file