Jump to content
  • Advertisement
Sign in to follow this  
p997

[.net] uneven FrameTime

This topic is 4354 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, why is the time the game takes to complete each frame cycle in the main loop different every time? i placed a variable FrameTime (FrameTime = m_StopWatch..ElapsedMilliseconds) at the end of the main loop to get the time it takes to complete each cycle. the outcome, FrameTime runs anywhere between 17-40, even when the game is paused. well, since the game is paused and there is no changes/new updates in its calculation, shouldn't the time to complete each cycle be more consistent? this uneven frame time is choking up the game play. while (GameRunning) { m_StopWatch.Reset(); m_StopWatch.Start(); KeyBoard.Update(); ProcessInput(); Render(); Application.DoEvents(); m_StopWatch.Stop(); frameTime = m_StopWatch.ElapsedMilliseconds; } is there something wrong with my code? thanks for any help/comment.

Share this post


Link to post
Share on other sites
Advertisement
How accurate is that timer? ... that's the obvious source of instability. Otherwise, vagaries of the OS and other applications that are running could be causing it. Are you doing special processing every 10 frames, or something? ... that would obviously make those frames slower.

Share this post


Link to post
Share on other sites
Chances are you are not only running the game, but also some processes in the background. It could be related to something the operating system does. (what Bob already said)

Since a paused game is pretty boring, you'll never get even frame times unless you fix the timestep to a set rate somehow (there's an article on that, but some forum searches will show you that not everyone is happy with it). Relying on a fixed step without fixing it yourself is probably already not a good idea just because of different pc hardware, not to mention events internal to your game. The other way is to do logic updates based on elapsed time, but this has a chance to screw up your integrations when the frame time changes drastically.

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.

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

Sign me up!