diff --git a/data/levels/level1.lua b/data/levels/level1.lua index 9e30c39..67a715a 100644 --- a/data/levels/level1.lua +++ b/data/levels/level1.lua @@ -1,14 +1,14 @@ return { - name = "level1", - tileset = tileset.library, - tiles = { - {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 0, 0, 0, 0, 0, 0}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} - }, - objects = {} -} + name = "test", + tileset = tileset.library, + tiles = { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} + }, + objects = {} +} \ No newline at end of file diff --git a/data/scripts/editor.lua b/data/scripts/editor.lua index efdeb25..d9a7bb4 100644 --- a/data/scripts/editor.lua +++ b/data/scripts/editor.lua @@ -24,6 +24,14 @@ function EditorStep() if love.keyboard.isDown("down", "s") then Camera.pos.y = Camera.pos.y + 3*game.scale end + + if Keybind:HasPressed(Keybind.debug.reload) then + ExportLevel("test") + end + + if Keybind:HasPressed(Keybind.debug.editor) then + editor_mode = false + end end function EditorScroll(y) diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index aa07b2c..2e92bda 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -27,7 +27,7 @@ o.dashDistance = 40 -- gameworld pixels o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels o.dashCount = 1 -- int - o.dashAmount = 0 -- int + o.dashAmount = 10 -- int o.boxCollision = { from = {x = -8, y = -16}, --gameworld pixels diff --git a/data/scripts/game.lua b/data/scripts/game.lua index 9ba6300..ecb4f1b 100644 --- a/data/scripts/game.lua +++ b/data/scripts/game.lua @@ -13,6 +13,31 @@ function GameStep() Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y) --camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) end + + if Keybind:HasPressed(Keybind.debug.debug) then + if debug then + debug = false + debug_collision = true + elseif debug_collision then + debug_collision = false + else + debug = true + end + end + + if Keybind:HasPressed(Keybind.debug.reposition) then + if not editor_mode then + main_Player.pos.x, main_Player.pos.y = 16,-10 + end + end + + if Keybind:HasPressed(Keybind.debug.reload) then + LoadLevel() + end + + if Keybind:HasPressed(Keybind.debug.editor) then + editor_mode = true + end end function GameDraw() diff --git a/data/scripts/in_out.lua b/data/scripts/in_out.lua index 47dcb8c..879a2a0 100644 --- a/data/scripts/in_out.lua +++ b/data/scripts/in_out.lua @@ -1,8 +1,47 @@ - -function getInput(filename) - local file = io.open(filename, "r") - io.input(file) - local content = io.read() - io.close(file) - return content +function ExportLevel(levelname) + filename = "output.lua" + local success, message = love.filesystem.write(filename, "") + if success then + love.filesystem.append(filename, "return {") + love.filesystem.append(filename, "\n name = \"" .. levelname .. "\",") + for k, v in pairs(tileset) do + if v == LevelData.tileset then + love.filesystem.append(filename, "\n tileset = tileset." .. k .. ",") + end + end + love.filesystem.append(filename, "\n tiles = {") + for i = 1, #LevelTiles do + love.filesystem.append(filename, "\n { ") + for j = 1, #LevelTiles[i] do + if j ~= 1 then + love.filesystem.append(filename, ", ") + end + love.filesystem.append(filename, tostring(LevelTiles[i][j].id)) + end + love.filesystem.append(filename, "}") + if i ~= #LevelTiles then + love.filesystem.append(filename, ", ") + end + end + love.filesystem.append(filename, "\n },") + love.filesystem.append(filename, "\n objects = {}") + love.filesystem.append(filename, "\n}") + end end + +--[[ +return { + name = "level1", + tileset = tileset.library, + tiles = { + {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 0, 0, 0, 0, 0, 0}, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} + }, + objects = {} +} +]] diff --git a/main.lua b/main.lua index c44925c..2a43e9a 100644 --- a/main.lua +++ b/main.lua @@ -80,35 +80,6 @@ function love.update(dt) --MenuStep if menuPage ~= nil then MenuStep(menuPage) end - if Keybind:HasPressed(Keybind.debug.debug) then - if debug then - debug = false - debug_collision = true - elseif debug_collision then - debug_collision = false - else - debug = true - end - end - - if Keybind:HasPressed(Keybind.debug.reposition) then - if not editor_mode then - main_Player.pos.x, main_Player.pos.y = 16,-10 - end - end - - if Keybind:HasPressed(Keybind.debug.reload) then - LoadLevel() - end - - if Keybind:HasPressed(Keybind.debug.editor) then - if editor_mode then - editor_mode = false - else - editor_mode = true - end - end - --editor if editor_mode then EditorStep()