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})