50 lines
1011 B
C
50 lines
1011 B
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_render();
|
||
|
//engine_sleep(33);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char **argv) {
|
||
|
for (int i = 0; i < argc; ++i) {
|
||
|
printf("argv[%d]: %s\n", i, argv[i]);
|
||
|
}
|
||
|
|
||
|
engine_init(96,64,"Game");
|
||
|
engine_luaInit();
|
||
|
|
||
|
while (1) {
|
||
|
struct ENGINE_EVENT event = engine_getEvent();
|
||
|
if (event.type != ENGINE_EVENT_TYPE_NONE) {
|
||
|
handleEvent(event);
|
||
|
} else {
|
||
|
tick();
|
||
|
}
|
||
|
}
|
||
|
}
|