Jump to content
  • Advertisement

Archived

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

politz2005

Capping Frame Rates

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

I''m having a problem with framerates going too fast. I''m moving based on a formula of pixels per a second, which I multiply times the framtime, you get the idea. Anyway, most the time I get manageable framerates like 450 fps which gives me a frametime of about .02 which .02 * say 200 pixels a second is about 3 However occasionally I get framerates of lie 13000 or something really high. This gives me a frametime of .000045. The precision is too high for my engine. I want to somehow cap the frame rate to something manageable. Maybe even like 500, as long as it doesn''t cause the appearence of slow down. Having a really high framerate unfortunately causes the game to look like its slowing down. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Instead of capping the framerate, instead move your objects based on the time elapsed since the last frame. Give your objects a speec (distance per second) and move based on that.

Share this post


Link to post
Share on other sites
actually that is what I am doing. I think I narrowed down the slowdown. For some reason whenever a key is pressed the framerate gets all weird. Any more ideas?

Share this post


Link to post
Share on other sites
Stupid me, I fixed the problem.

Here it was

if(PeekMessage()) etc
handle message

else
do loop


Well, when a key is pressed it tells windows to handle the message and the entire frame was skipped.
Now, it does both.

Share this post


Link to post
Share on other sites
in any event, you might just consider switching to a system that measures time in ticks of 1,000,000 instead of 1,000

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!