From e285bcd4fd0618a69c476151d02b821077d409d0 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sun, 1 Jun 2025 00:04:30 +0200 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20Renombrat=20de=20una=20puta=20vegad?= =?UTF-8?q?a=20el=20mapa=20"test"=20a=20"arq"=20(arquitectura),=20que=20es?= =?UTF-8?q?=20la=20zona=20que=20li=20toca=20-=20[NEW]=20Nou=20men=C3=BAi?= =?UTF-8?q?=20de=20debug=20durant=20el=20joc=20-=20[NEW]=20Ara=20es=20pot?= =?UTF-8?q?=20pasar=20del=20joc=20al=20editor=20i=20viceversa=20in=20situ.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/{test.map => arq.map} | 0 data/editor.lua | 17 +++++++++++++++++ data/game.lua | 19 +++++++++++++++++++ data/m_arq.lua | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) rename data/{test.map => arq.map} (100%) diff --git a/data/test.map b/data/arq.map similarity index 100% rename from data/test.map rename to data/arq.map diff --git a/data/editor.lua b/data/editor.lua index 141f728..2629849 100644 --- a/data/editor.lua +++ b/data/editor.lua @@ -9,6 +9,8 @@ editor={ --selected_tile=3, brush={w=1,h=1,tiles={3}}, selection=nil, + cx=0, + cy=0, init=function() set_update(editor.update) @@ -16,6 +18,15 @@ editor={ editor.new() end, + editfrom=function() + game.paused = nil + set_update(editor.update) + --editor.show_menu() + editor.load(game.level .. ".map") + editor.cam.x = game.cam.x + editor.cam.y = game.cam.y + end, + show_menu=function() menu.show({ {"NEW MAP", editor.new}, {"LOAD MAP", function() fileselect.show("FILE TO LOAD:",editor.load, ".map") end}, @@ -23,10 +34,15 @@ editor={ {editor.editing_front_layer and "DISABLE FRONT LAYER" or "ENABLE FRONT LAYER", editor.toggle_front_layer}, {"RESIZE MAP", editor.resize}, {"RELOAD TEXTURES", editor.reload_textures}, + {"PLAY FROM HERE", editor.playfromhere}, {"EXIT", main_init}, }, function()editor.paused=false end) end, + playfromhere=function() + game.startfromeditor(string.sub(mapa.name,1,-5), editor.cx, editor.cy) + end, + reload_textures=function() surf.free(sprites) surf.free(objectes) @@ -175,6 +191,7 @@ editor={ end local mx,my=mouse.pos() local tx,ty=(mx+editor.cam.x)>>3,(my+editor.cam.y)>>3 + editor.cx, editor.cy = tx, ty local rx,ry=tx<<3,ty<<3 draw.rect(rx-1, ry-1, 10, 10, 10) if editor.selection then diff --git a/data/game.lua b/data/game.lua index 3b86a9c..ef9f171 100644 --- a/data/game.lua +++ b/data/game.lua @@ -30,6 +30,15 @@ game={ --game.init("arq") end, + startfromeditor=function(s_level, s_x, s_y) + flags={} + objects.list={} + actors.main={name="jailer",x=s_x,y=s_y,o="d",gfx={x=32,y=0},level=s_level} + game.init(s_level) + --actors.main={name="jailer",x=8,y=12,o="l",gfx={x=32,y=0},level="arq"} + --game.init("arq") + end, + init=function(levelname,f,objs) if f then flags=f end @@ -61,6 +70,14 @@ game={ }, game.resume) end, + show_debug_menu=function() + game.pause() + menu.show({ {"EDIT FROM HERE", editor.editfrom}, + {"CARREGAR PARTIDA", game.load}, + {"EIXIR", main_init}, + }, game.resume) + end, + save=function() local i=1 file = io.open(config.folder().."slot"..i..".txt", "w") @@ -188,6 +205,8 @@ game={ end if key.press(key.ESCAPE) then game.show_menu() + elseif key.press(key.TAB) then + game.show_debug_menu() end if sys.beat() then actors.update() end diff --git a/data/m_arq.lua b/data/m_arq.lua index 7dd278c..044e7e4 100644 --- a/data/m_arq.lua +++ b/data/m_arq.lua @@ -1,6 +1,6 @@ levels["arq"]={ load=function() - mapa.load("test.map") + mapa.load("arq.map") actors.add({name="prohibit1",x=6,y=10,o="d",gfx={x=192,y=48},action=levels.arq.prohibit_action}) actors.add({name="prohibit2",x=12,y=10,o="d",gfx={x=192,y=48},action=levels.arq.prohibit_action})