internal void Flush() { if (Active) { PerfTime now = PerfTime.Now; TotalTime += (now - StartTime); StartTime = now; } }
internal void Resume() { if (_paused) { PerfTimeSpan pauseDelta = PerfTime.Now - _pauseStarted; _lastFrameTime += pauseDelta; _lastFpsTime += pauseDelta; _paused = false; } }
internal GameTime() { _lastFrameTime = PerfTime.Now; _lastFpsTime = _lastFrameTime; }
internal void Pause() { if (!_paused) { _paused = true; _pauseStarted = PerfTime.Now; } }
internal void UpdateFrame() { PerfTime thisFrameSnapshot = PerfTime.Now; PerfTimeSpan timeDelta = thisFrameSnapshot - _lastFrameTime; PerfTimeSpan fpsTimeDelta = thisFrameSnapshot - _lastFpsTime; _frameCounter++; _fpsFrameCounter++; if (fpsTimeDelta.Seconds >= _fpsMeasureTimeFrame) { _fps = (_fpsFrameCounter) / (float)fpsTimeDelta.Seconds; _fpsFrameCounter = 0; _lastFpsTime = thisFrameSnapshot; } _frameTime = Math.Min((float)timeDelta.Seconds, MAX_TIME_DELTA); _totalGameTime += _frameTime; _lastFrameTime = thisFrameSnapshot; }