Level exporting works!
This commit is contained in:
parent
35c260d24f
commit
a703af5e8d
|
@ -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 = {}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 = {}
|
||||
}
|
||||
]]
|
||||
|
|
29
main.lua
29
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()
|
||||
|
|
Loading…
Reference in New Issue