unnamed-platformer/levels.lua

36 lines
851 B
Lua
Raw Normal View History

2020-02-11 11:44:37 +01:00
levels = {[[
2020-02-12 13:33:41 +01:00
00000000000000000000000000
00000000000000000000000000
00......................00
00......................00
00......................00
00.........v............00
00.........00...........00
00.........00...........00
00................v.....00
00...............0v.....00
00......................00
00........v00...........00
00.s.....vv00...........00
00000000000000000000000000
00000000000000000000000000
2020-02-11 11:44:37 +01:00
]]
}
to_write = ""
--remove all "\n" from level strings
for i, v in ipairs(levels) do
v = string.gsub(v, "\n", "")
2020-02-11 13:55:57 +01:00
to_write = to_write.." case "..(i-1)..":\n memcpy(level, \""..v.."\", "..#v..");\n break;"
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(unsigned char level_id, char *level) {
2020-02-11 11:44:37 +01:00
switch (level_id)
{
]]..to_write.."\n }\n}\n"
io.write(to_write)