Jump to content
  • Advertisement
Sign in to follow this  
coderWalker

Dropping Frames to regulate game speed

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

Problem:
My game currently lags pretty bad at some points.
The game is still getting 60FPS meaning that the actual speed of the game slows.
I think this is making the lag appear worse than it actually is (I hope).

I know I have to time the frames and somehow drop frames.
What I want is the frame rate to drop to allow the processing to catch up.
How do I go about doing this?

I have something to regulate FPS >60 down to 60:
while (fps->get_ticks() < 1000 / FRAMES_PER_SECOND)
{
while (world0->taskPerform()==false) {}
}

Now I need something to check weither or not the time has went over 1000 / FRAMES_PER_SECOND right?

Thanks,
Walker

Share this post


Link to post
Share on other sites
Advertisement
get_ticks() returns the amount of milliseconds since the timer was reset, and I reset it before drawing the frame.
FPS Frames Per Second

Share this post


Link to post
Share on other sites
while (app_is_running)
{
// the condition must be chacked each frame because the application is already a loop.
if ( (get_ticks() - last_ticks) > 1000/FPS)
{
update_state_without_drawing(); // Updates whatever data
last_ticks = get_ticks();
}

draw_either_scene_changed_or_not(); // Draws everything each frame, if it didn't change it'd look the same for some milliseconds.
}




EDIT: Input management should go outside the if.

Share this post


Link to post
Share on other sites
I generally do the opposite.

I let the program render flat out and regulate things by checking the time since last frame.

So, on a basic scene my rig can put out 8000 FPS and another PC might do 1000 to 2000 FPS but the timing is still fine and objects move at the same rate on any system.

Share this post


Link to post
Share on other sites

I generally do the opposite.

I let the program render flat out and regulate things by checking the time since last frame.

So, on a basic scene my rig can put out 8000 FPS and another PC might do 1000 to 2000 FPS but the timing is still fine and objects move at the same rate on any system.


I have noticed dropping frames really causes no speed-up what-so-ever.
Can you elaborate more on your method, or post some source?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!