forked from Fierelier/me.fier.engine
51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "modules/engine/main.c"
|
|
#include "modules/engine/frontend/sdl/main.c"
|
|
#include "modules/engine/frontend/generic/textures.c"
|
|
#include "modules/engine/addon/lua.c"
|
|
|
|
void handleEvent(struct ENGINE_EVENT * event) {
|
|
if (event->type == ENGINE_EVENT_TYPE_EXIT) {
|
|
exit(0);
|
|
}
|
|
}
|
|
|
|
int frame = 0;
|
|
int frameSec = 0;
|
|
Uint32 lastSec = 0;
|
|
|
|
void tick() {
|
|
frame += 1;
|
|
frameSec += 1;
|
|
unsigned long tick = engine_time_get();
|
|
if (tick - lastSec >= 1000) {
|
|
printf("FPS: %d\n",frameSec);
|
|
lastSec = tick;
|
|
frameSec = 0;
|
|
}
|
|
luaL_loadstring(engine_lua_state,"engine_onFrame()");
|
|
lua_call(engine_lua_state,0,0);
|
|
engine_window_present();
|
|
//engine_time_sleep(33);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
for (int i = 0; i < argc; ++i) {
|
|
printf("argv[%d]: %s\n", i, argv[i]);
|
|
}
|
|
|
|
engine_window_init(96,64,"Game");
|
|
engine_luaInit();
|
|
|
|
while (1) {
|
|
struct ENGINE_EVENT * event = engine_event_get();
|
|
if (event->type != ENGINE_EVENT_TYPE_NONE) {
|
|
handleEvent(event);
|
|
} else {
|
|
tick();
|
|
}
|
|
engine_free(event);
|
|
}
|
|
}
|