add fps util for pxl8 in lua
This commit is contained in:
parent
7dd32ec453
commit
5637fa18c8
9 changed files with 57 additions and 76 deletions
|
|
@ -79,9 +79,12 @@ static const char* pxl8_ffi_cdefs =
|
|||
"typedef float f32;\n"
|
||||
"typedef double f64;\n"
|
||||
"typedef struct pxl8_gfx pxl8_gfx;\n"
|
||||
"typedef struct pxl8_game pxl8_game;\n"
|
||||
"typedef struct { int x, y, w, h; } pxl8_bounds;\n"
|
||||
"typedef struct { int x, y; } pxl8_point;\n"
|
||||
"\n"
|
||||
"f32 pxl8_game_get_fps(const pxl8_game* game);\n"
|
||||
"\n"
|
||||
"i32 pxl8_gfx_get_height(pxl8_gfx* ctx);\n"
|
||||
"i32 pxl8_gfx_get_width(pxl8_gfx* ctx);\n"
|
||||
"void pxl8_circle(pxl8_gfx* ctx, i32 x, i32 y, i32 r, u32 color);\n"
|
||||
|
|
@ -408,6 +411,14 @@ void pxl8_script_set_ui(pxl8_script* script, pxl8_ui* ui) {
|
|||
}
|
||||
}
|
||||
|
||||
void pxl8_script_set_game(pxl8_script* script, void* game) {
|
||||
if (!script) return;
|
||||
if (script->L && game) {
|
||||
lua_pushlightuserdata(script->L, game);
|
||||
lua_setglobal(script->L, "_pxl8_game");
|
||||
}
|
||||
}
|
||||
|
||||
static pxl8_result pxl8_script_prepare_path(pxl8_script* script, const char* filename, char* out_basename, size_t basename_size) {
|
||||
char filename_copy[PATH_MAX];
|
||||
strncpy(filename_copy, filename, sizeof(filename_copy) - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue