So I might be missing the obvious but I have been reading Dewitters game loops http://www.koonsolo.com/news/dewitters-gameloop/ and I'm thinking about using;
const int TICKS_PER_SECOND = 50;
const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
const int MAX_FRAMESKIP = 10;
DWORD next_game_tick = GetTickCount();
int loops;
bool game_is_running = true;
while( game_is_running ) {
loops = 0;
while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) {
update_game();
next_game_tick += SKIP_TICKS;
loops++;
}
display_game();
}
Now implementing the above is easypeasy
Const TICKS_PER_SECOND:Int = 50
Const SKIP_TICKS:Int = 1000 / TICKS_PER_SECOND
Const MAX_FRAMESKIP:Int = 10
Global next_game_tick:Int = MilliSecs()
Global loops:Int
loops = 0
While (MilliSecs() > next_game_tick And loops < MAX_FRAMESKIP)
Game.Update
next_game_tick:+SKIP_TICKS
loops:+1
Wend
Game.Render
I fail to see what 'loops' is doing also the next_game_tick seems all wrong, should it not be millisecs() + SKIP_TICKS?
|