I want to normalize FPS.
fact is that with the appearance of those or other particles also appearance lags.
Code: Select all
int dx;
int dy;
...
while(TRUE)
{
handleInput();
drawObjects();
drawParticles1();
drawParticles2();
SPR_update(sprites, 80);
VDP_waitVSync();
}
I tried as follows.
But anything sensible did not work.
Code: Select all
int TICKS_PER_SECOND;
int SKIP_TICKS;
int MAX_FRAMESKIP ;
u32 next_game_tick = getTick();
int loops;
...
int main(){
loops = 0;
MAX_FRAMESKIP = 10;
TICKS_PER_SECOND = 50;
SKIP_TICKS = 1000 / TICKS_PER_SECOND;
while(TRUE)
{
while( getTick() > next_game_tick && loops < MAX_FRAMESKIP)
{
handleInput();
drawObjects();
drawParticles1();
drawParticles2();
next_game_tick += SKIP_TICKS;
loops++;
}
SPR_update(sprites, 80);
VDP_waitVSync();
}
}