Jump to content
  • Advertisement

Archived

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

lakibuk

constant framerate

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

Advertisement
You have to use your own timer functions... so at the beggining of your main loop you get some sort of start time and at the end you subtract the start time from the end time to get how long the loop was and "wait" the extra time, before you start your next frame. The reason I put wait in quotes is because some brilliant programmers will use this *extra* time wisely and calculate things and prepare for the next frame in that time, so your never really wasting cpu cycles...
See ya,
Ben

P.S. There are many example sin the DX7.0a SDK.. Look for yourself..

Share this post


Link to post
Share on other sites
The best idea is to seperate your Drawing code from your Update code, and run as fast as possible.

Instead of limiting the FPS, you run as fast as possible on any machine - but the animations are still limited to a certain speed.

For example - let's pretend you move your characters at a steady 5 pixels every update. If the Update and Drawing code are together, then if the frame rate goes up, the character looks like he's moving too quickly.

Instead, you could move the character by 5 times a certain modifier... the modifier is determined by the frame rate. So if the game is running super fast on a computer, you move the character 1 pixel a second.. or even less. The animation can be figured out the same way - you only advance a frame if it needs it.

//begin code

float fpsDelta = GetFPSDelta();

UpdateAllSprites(fpsDelta);
DrawAllSprites();

//end code

Let's pretend that GetFPSDelta retrieves the current Frames Per Second. Assuming that UpdateAllSprites will move all sprites by a certain amount depending on that Delta. Also, UpdateAllSprites will only advance to the next frame in a sprite's animation if a certain amount of time has passed since the last frame.

Sorry this is all theory with no code...

Clay

Edited by - Falagard on June 22, 2000 7:56:14 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!