Sign in to follow this  

Measured Progress

This topic is 2658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. In my learning about game programming, I've seen two different ways to keep the progress of a game constant. Either there is -
A - Constant sleep intervals (10-20ms) while the game update function checks how long it's been since it's last running and advances things based on that (if speed = 2m/s and .21 seconds have passed, move 0.42m.)
B - Varied sleep intervals with an intended updates-per-second (UPS) apart from the FPS. If a frame takes a long time to render then it updates extra times for the frame's rendering.

Mind, these were in Python and Java respectively. So my question is if one is inherently better than the other for a game? Or if one is preferable based on what kind of graphics/game?

Share this post


Link to post
Share on other sites
Both seem the same to me but B is more recognisable.

A = Check the last time Update function was to run

B = Check the amount of time the last frame took to render.

I use B but as long as your "Update" function is part of your game loop then it doesn't really matter either way.


void main() {

float lastUpdate; // These should be somewhere smarter
float difference; // These should be somewhere smarter

while (isRunning == true) {

DoStuff();


difference = Ticks-lastUpdate;
lastUpdate = Ticks;

}

}


Share this post


Link to post
Share on other sites

This topic is 2658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this