Level exporting works!
This commit is contained in:
parent
35c260d24f
commit
a703af5e8d
|
@ -1,13 +1,13 @@
|
||||||
return {
|
return {
|
||||||
name = "level1",
|
name = "test",
|
||||||
tileset = tileset.library,
|
tileset = tileset.library,
|
||||||
tiles = {
|
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, 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, 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,37,38, 6,37,38, 7, 0, 5,37,38, 7, 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, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7, 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, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7, 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}
|
{ 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 = {}
|
objects = {}
|
||||||
|
|
|
@ -24,6 +24,14 @@ function EditorStep()
|
||||||
if love.keyboard.isDown("down", "s") then
|
if love.keyboard.isDown("down", "s") then
|
||||||
Camera.pos.y = Camera.pos.y + 3*game.scale
|
Camera.pos.y = Camera.pos.y + 3*game.scale
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Keybind:HasPressed(Keybind.debug.reload) then
|
||||||
|
ExportLevel("test")
|
||||||
|
end
|
||||||
|
|
||||||
|
if Keybind:HasPressed(Keybind.debug.editor) then
|
||||||
|
editor_mode = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function EditorScroll(y)
|
function EditorScroll(y)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
o.dashDistance = 40 -- gameworld pixels
|
o.dashDistance = 40 -- gameworld pixels
|
||||||
o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels
|
o.dashSpeed = o.dashDistance / (o.dashTime*60) -- pixels
|
||||||
o.dashCount = 1 -- int
|
o.dashCount = 1 -- int
|
||||||
o.dashAmount = 0 -- int
|
o.dashAmount = 10 -- int
|
||||||
|
|
||||||
o.boxCollision = {
|
o.boxCollision = {
|
||||||
from = {x = -8, y = -16}, --gameworld pixels
|
from = {x = -8, y = -16}, --gameworld pixels
|
||||||
|
|
|
@ -13,6 +13,31 @@ function GameStep()
|
||||||
Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
|
Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
|
||||||
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
|
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function GameDraw()
|
function GameDraw()
|
||||||
|
|
|
@ -1,8 +1,47 @@
|
||||||
|
function ExportLevel(levelname)
|
||||||
function getInput(filename)
|
filename = "output.lua"
|
||||||
local file = io.open(filename, "r")
|
local success, message = love.filesystem.write(filename, "")
|
||||||
io.input(file)
|
if success then
|
||||||
local content = io.read()
|
love.filesystem.append(filename, "return {")
|
||||||
io.close(file)
|
love.filesystem.append(filename, "\n name = \"" .. levelname .. "\",")
|
||||||
return content
|
for k, v in pairs(tileset) do
|
||||||
|
if v == LevelData.tileset then
|
||||||
|
love.filesystem.append(filename, "\n tileset = tileset." .. k .. ",")
|
||||||
end
|
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
|
--MenuStep
|
||||||
if menuPage ~= nil then MenuStep(menuPage) end
|
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
|
--editor
|
||||||
if editor_mode then
|
if editor_mode then
|
||||||
EditorStep()
|
EditorStep()
|
||||||
|
|
Loading…
Reference in New Issue