Integrated the UP-editor system.

This commit is contained in:
KikooDX 2020-02-25 11:06:54 +01:00
parent e8508ee33e
commit 1b02d355e5
3 changed files with 26 additions and 136 deletions

3
editor.sh Executable file
View File

@ -0,0 +1,3 @@
cd ../up-editor/
love .
cd ../platformer

View File

@ -1,143 +1,30 @@
-- . air
-- 0 solid
-- - placeholder tile
-- v spike
-- ^ elevator
-- ~ ice
-- # glue
-- j jump upgrade
-- c coin
--
-- level id format : YYXX with YY and XX being the Y and X position on the map
levels = {[5050] = [[
----------------------------
-0000000....000000000000000-
-0000000....000000000000000-
-00000000....00000.........-
-00000000..................-
-00000000...........0000000-
-0000000000.....00000000000-
-0000000000.....00000000000-
-00000000...........0000000-
-00000..............0000000-
-.............0000000000000-
-..........0000000000000000-
-00000000000000000000000000-
-00000000000000000000000000-
-00000000000000000000000000-
-00000000000000000000000000-
----------------------------
]],
[5049] = [[
----------------------------
-00000000000000000000000000-
-00000000000000000000000000-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-........................00-
-........................00-
-00........................-
-000.......................-
-000.0000000000000000000000-
-..........0000000000000000-
-00000000..0000000000000000-
-00000000..0000000000000000-
----------------------------
]],
[5048] = [[
----------------------------
-00000000000000000000000000-
-00000000000000000000000000-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00........................-
-00........................-
-00.................0000000-
-00.................0000000-
-00.................0000000-
-00.................00..c..-
-000000000000000000000.0000-
-000000000000000000000.0000-
----------------------------
]],
[5148] = [[
----------------------------
-000000000000000000000.0000-
-000000000000000000000.....-
-00..................000000-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00000000000000000000000000-
-00000000000000000000000000-
----------------------------
]],
[5149] = [[
----------------------------
-00000000..0000000000000000-
-...00000..0000000000000000-
-00......................00-
-00......................00-
-0000000000000000..vv000000-
-0000000000000000...0000000-
-00000......0000.......0000-
-000.........00....00...000-
-00^.........00.........000-
-00^.j................00000-
-00^....................000-
-00^.........0^.........000-
-0000^.......0^.......00000-
-00000000000000000000000000-
-00000000000000000000000000-
----------------------------
]],
[0] = [[
----------------------------
-00000000000000000000000000-
-00000000000000000000000000-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00......................00-
-00000000000000000000000000-
-00000000000000000000000000-
----------------------------
]],
}
to_write = ""
--remove all "\n" from level strings
current = 0
for i, v in pairs(levels) do
v = string.gsub(v, "\n", "")
to_write = to_write.." case "..i..":\n memcpy(level, \""..v.."\", "..#v..");\n"
if string.find(v, 'c') then
to_write = to_write.." *coin_id = "..current..";\n"
for i = 0, 9999, 1 do
file = io.open("../up-editor/screens/"..i..".scr")
if file then
file_content = file:read()
formated_file = ""
for j = 1, #file_content, 1 do
if j == 1 then
formated_file = formated_file.."-----------------------------"
end
formated_file = formated_file..file_content:sub(j, j)
if j % 26 == 0 then formated_file = formated_file.."--" end
if j == 390 then
formated_file = formated_file.."---------------------------"
end
end
file:close()
to_write = to_write.." case "..i..":\n memcpy(level, \""..
formated_file.."\", "..#formated_file..");\n"
if string.find(file_content, 'c') then
to_write = to_write.." *coin_id = "..current..";\n"
end
to_write = to_write.." break;\n"
current = current + 1
end
to_write = to_write.." break;\n"
current = current + 1
end
--finish and write

Binary file not shown.