debugging and delta ms

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • RE: debugging and delta ms

      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

      1. void Application::UpdateGameTimers(void)
      2. {
      3. // figure out timing
      4. unsigned long oldGameTime = m_gameTimeMs;
      5. m_gameTimeMs = OS::GetTickCount();
      6. m_lastDeltaMs = m_gameTimeMs - oldGameTime;
      7. #ifndef NDEBUG
      8. // If we get a really long turn, assume we were in the debugger or something and pretend that only 1/30
      9. // of a second went by. Yeah, this is kind of a hack, which is why we don't do it in Release mode.
      10. if (m_lastDeltaMs > 5000)
      11. m_lastDeltaMs = 33;
      12. #endif
      13. }
      Display All


      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