• Create Account

Banner advertising on our site currently available from just \$5!

### #ActualTispe

Posted 06 July 2013 - 04:18 AM

You can maybe get away with using Sleep(1).

I would decouple update_game() from render_game(). Such that update_game() works independently on FPS. Which means you need to pass it the elapsed time every time you call it and only update incrementally based on elapsed time. That way animation will be smooth and consistant regardless of FPS. This will cure your stuttering problems.

GameTimer FrameTimer;
GameTimer UpdateTimer;
while(run_game) {

update_game(UpdateTimer.Tick());

if(FrameTimer.HasElapsed(20)) {
render_game();
} else {
Sleep(1);
}

}


### #3Tispe

Posted 06 July 2013 - 04:16 AM

You can maybe get away with using Sleep(1).

I would decouple update_game() from render_game(). Such that update_game() works independently on FPS. Which means you need to pass it the elapsed time every time you call it and only update incrementally based on elapsed time. That way animation will be smooth and consistant regardless of FPS. This will cure your stuttering problems.

GameTimer FrameTimer;
GameTimer UpdateTimer;
while(run_game) {
if(FrameTimer.HasElapsed(20)) {

render_game();
} else {
update_game(UpdateTimer.Tick());
Sleep(1);
}
}


### #2Tispe

Posted 06 July 2013 - 04:16 AM

You can maybe get away with using Sleep(1).

I would decouple update_game() from render_game(). Such that update_game() works independently on FPS. Which means you need to pass it the elapsed time every time you call it and only update incrementally based on elapsed time. That way animation will be smooth and consistant regardless of FPS. This will cure your stuttering problems.

GameTimer FrameTimer;
GameTimer UpdateTimer;
while(run_game) {
if(FrameTimer.HasElapsed(20)) {

render_game();
} else {
update_game(UpdateTimer.Tick());
Sleep(0);
}
}


### #1Tispe

Posted 06 July 2013 - 04:13 AM

You can maybe get away with using Sleep(1).

I would decouple update_game() from render_game(). Such that update_game() works independently on FPS. Which means you need to pass it the elapsed time every time you call it and only update incrementally based on elapsed time. That way animation will be smooth and consistant regardless of FPS. This will cure your stuttering problems.

PARTNERS