debugging and delta ms
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Yes, this is a problem that every single game faces. There's no easy way to subtract out the debugging time and it's usually not worth the hassle. The solution I use is trivially simple and works just fine:
Source Code
- void Application::UpdateGameTimers(void)
- {
- // figure out timing
- unsigned long oldGameTime = m_gameTimeMs;
- m_gameTimeMs = OS::GetTickCount();
- m_lastDeltaMs = m_gameTimeMs - oldGameTime;
- #ifndef NDEBUG
- // If we get a really long turn, assume we were in the debugger or something and pretend that only 1/30
- // of a second went by. Yeah, this is kind of a hack, which is why we don't do it in Release mode.
- if (m_lastDeltaMs > 5000)
- m_lastDeltaMs = 33;
- #endif
- }
This function is called once a frame at the top of my Application::Update() method. m_lastDeltaMs is passed into the various update functions that need a delta time between frames. In non-release builds, if it takes more than five seconds to process a frame, I assume that the game was locked in the debugger and force the delta to be 33ms.
-Rez -
-
Heh cool fix. Do you ever actually resume at 4.5 seconds, do a huge jump, and then try to debug it for a few minutes before remembering that that hack doesn't kick in until 5 seconds?
James
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0