Skip to content
Snippets Groups Projects
Commit a82f81eb authored by dg's avatar dg
Browse files

oh man .. need to optimize the AIs...

git-svn-id: http://svn.net-core.org/repos/t-engine4@85 51575b47-30f0-44d4-a5cc-537603b46e54
parent 40fbca10
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,9 @@ void on_event(SDL_Event *event)
// redraw the screen and update game logics, if any
void on_tick()
{
static int Frames = 0;
static int T0 = 0;
if (current_game != LUA_NOREF)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
......@@ -188,6 +191,19 @@ void on_tick()
lua_rawgeti(L, LUA_REGISTRYINDEX, current_game);
docall(L, 1, 0);
}
/* Gather our frames per second */
Frames++;
{
int t = SDL_GetTicks();
if (t - T0 >= 1000) {
float seconds = (t - T0) / 1000.0;
float fps = Frames / seconds;
printf("%d ticks in %g seconds = %g TPS\n", Frames, seconds, fps);
T0 = t;
Frames = 0;
}
}
}
void on_redraw()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment