unnamed-platformer/levels.lua

150 lines
3.8 KiB
Lua
Raw Normal View History

-- . air
-- 0 solid
-- - placeholder tile
-- v spike
-- ^ elevator
2020-02-17 15:47:02 +01:00
-- ~ ice
2020-02-17 16:10:41 +01:00
-- # glue
2020-02-14 11:10:06 +01:00
-- j jump upgrade
--
-- 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.........-
2020-02-14 11:10:06 +01:00
-00000000..................-
-00000000...........0000000-
-0000000000.....00000000000-
-0000000000.....00000000000-
-00000000...........0000000-
-00000..............0000000-
2020-02-14 11:10:06 +01:00
-.............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] = [[
2020-02-14 11:10:06 +01:00
----------------------------
-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-
2020-02-14 11:10:06 +01: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-
2020-02-14 11:10:06 +01:00
----------------------------
]],
[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-
----------------------------
]],
2020-02-11 11:44:37 +01:00
}
to_write = ""
--remove all "\n" from level strings
current = 0
2020-02-14 11:10:06 +01:00
for i, v in pairs(levels) do
2020-02-11 11:44:37 +01:00
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"
end
to_write = to_write.." break;\n"
current = current + 1
2020-02-11 11:44:37 +01:00
end
--finish and write
to_write = [[#include "levels.h"
2020-02-11 13:55:57 +01:00
#include <gint/std/string.h>
void set_level(int level_id, char level[], unsigned int *coin_id) {
2020-02-11 11:44:37 +01:00
switch (level_id)
{
]]..to_write.." }\n}\n"
2020-02-11 11:44:37 +01:00
io.write(to_write)