|
diff --git a/main.c b/main.c
|
| ... |
| 5 |
#include "lualib.h" |
5 |
#include "lualib.h" |
| 6 |
#include "lauxlib.h" |
6 |
#include "lauxlib.h" |
| 7 |
|
7 |
|
|
|
8 |
#include "stdlib/json.h" |
| 8 |
#include "stdlib/color.h" |
9 |
#include "stdlib/color.h" |
| 9 |
#include "stdlib/json.h" |
10 |
#include "stdlib/tilemap.h" |
| 10 |
|
11 |
|
| 11 |
#define IN_FILE "test/main.lua" |
12 |
#define IN_FILE "test/main.lua" |
| 12 |
#define DEBUG_LEVEL LOG_DEBUG |
13 |
#define DEBUG_LEVEL LOG_DEBUG |
| ... |
| 97 |
lua_register(L, "draw_fps", l_draw_fps); |
98 |
lua_register(L, "draw_fps", l_draw_fps); |
| 98 |
lua_register(L, "clear_window", l_clear_window); |
99 |
lua_register(L, "clear_window", l_clear_window); |
| 99 |
|
100 |
|
|
|
101 |
// Embedding JSON module. |
|
|
102 |
if (luaL_loadbuffer(L, json, json_len, "json") || lua_pcall(L, 0, 1, 0)) { |
|
|
103 |
fprintf(stderr, "Error loading json.lua: %s\n", lua_tostring(L, -1)); |
|
|
104 |
lua_close(L); |
|
|
105 |
return 1; |
|
|
106 |
} |
|
|
107 |
lua_setglobal(L, "json"); |
|
|
108 |
|
| 100 |
// Embedding color module. |
109 |
// Embedding color module. |
| 101 |
if (luaL_loadbuffer(L, color, color_len, "color") || lua_pcall(L, 0, 1, 0)) { |
110 |
if (luaL_loadbuffer(L, color, color_len, "color") || lua_pcall(L, 0, 1, 0)) { |
| 102 |
fprintf(stderr, "Error loading color.lua: %s\n", lua_tostring(L, -1)); |
111 |
fprintf(stderr, "Error loading color.lua: %s\n", lua_tostring(L, -1)); |
| ... |
| 105 |
} |
114 |
} |
| 106 |
lua_setglobal(L, "color"); |
115 |
lua_setglobal(L, "color"); |
| 107 |
|
116 |
|
| 108 |
// Embedding JSON module. |
117 |
// Embedding tilemap module. |
| 109 |
if (luaL_loadbuffer(L, json, json_len, "json") || lua_pcall(L, 0, 1, 0)) { |
118 |
if (luaL_loadbuffer(L, tilemap, tilemap_len, "tilemap") || lua_pcall(L, 0, 1, 0)) { |
| 110 |
fprintf(stderr, "Error loading json.lua: %s\n", lua_tostring(L, -1)); |
119 |
fprintf(stderr, "Error loading tilemap.lua: %s\n", lua_tostring(L, -1)); |
| 111 |
lua_close(L); |
120 |
lua_close(L); |
| 112 |
return 1; |
121 |
return 1; |
| 113 |
} |
122 |
} |
| 114 |
lua_setglobal(L, "json"); |
123 |
lua_setglobal(L, "tilemap"); |
| 115 |
|
124 |
|
| 116 |
// Interpreting and running input file Lua script. |
125 |
// Interpreting and running input file Lua script. |
| 117 |
if (luaL_loadfile(L, IN_FILE) || lua_pcall(L, 0, 0, 0)) { |
126 |
if (luaL_loadfile(L, IN_FILE) || lua_pcall(L, 0, 0, 0)) { |
| ... |
|
diff --git a/stdlib/tilemap.h b/stdlib/tilemap.h
|
| ... |
| 2 |
#define tilemap_H |
2 |
#define tilemap_H |
| 3 |
|
3 |
|
| 4 |
unsigned char tilemap[] = { |
4 |
unsigned char tilemap[] = { |
| 5 |
0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, |
5 |
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x69, 0x6c, 0x65, 0x6d, 0x61, |
| 6 |
0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, |
6 |
0x70, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x0a, 0x72, 0x65, 0x74, 0x75, |
| 7 |
0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x70, 0x6f, |
7 |
0x72, 0x6e, 0x20, 0x74, 0x69, 0x6c, 0x65, 0x6d, 0x61, 0x70, 0x0a |
| 8 |
0x74, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x73, 0x74, 0x61, 0x6e, |
|
|
| 9 |
0x64, 0x61, 0x72, 0x64, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, |
|
|
| 10 |
0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, |
|
|
| 11 |
0x73, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x66, 0x72, 0x61, |
|
|
| 12 |
0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, |
|
|
| 13 |
0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x20, 0x66, |
|
|
| 14 |
0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x69, |
|
|
| 15 |
0x65, 0x73, 0x2e, 0x0a |
|
|
| 16 |
}; |
8 |
}; |
| 17 |
unsigned int tilemap_len = 124; |
9 |
unsigned int tilemap_len = 35; |
| 18 |
|
10 |
|
| 19 |
#endif // tilemap_H |
11 |
#endif // tilemap_H |