Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

chox

How can I determine number of loop counter between state?

This topic is 6710 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

How can I determine number of counter in game loop for take some actions from the different CPU speed ? example : Non players have their state, they have to loop until some values and then go to next state. But the same values of loop counte makes different time consumption for difference CPU speed. How can I fix it ? Thank you very much

Share this post


Link to post
Share on other sites
Advertisement
I think you''re approaching the whole "framerate issue" backwards.

You don''t want to try and time things when processing your frames. Instead, you want to let the game run as fast as it can, and then time how fast that particular frame took. Use this newly calculate value to process things next frame.

For example :

float Frametime; // in milliseconds
while(game_is_running){
process_game_stuff(Frametime);
render_frame();

Frametime = calculate_THIS_frametime();
}

You''ll probably want to add a framerate cap as well. So if your game is running too fast, just cap it at 60 fps (ie, if its faster, just physically _wait_ until 1/60th of a second has passed total for the frame). Also, if your framerate is really low, bash Frametime by hand to something reasonable like 1/4 of a second so that your game "chugs" its way along when it needs to.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!