public GameClock() { GameTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero); }
/// <summary> /// Updates GameTime. /// </summary> public void Tick() { // Simulates fluctuations in minute timing. double variance = (r.Next((int)(100d * TimeMultiplier)) / 100d) - (r.Next((int)(100d * TimeMultiplier)) / 100d); int timeDelta = (int)Math.Round(baseTimePerInterval * Math.Abs((TimeMultiplier + variance))); // at least 1 ms passed. if (timeDelta == 0) timeDelta = 1; totalIntervals += timeDelta; totalTime = new TimeSpan(0, 0, 0, 0, totalIntervals); elapsedTime = new TimeSpan(0, 0, 0, 0, timeDelta); this.GameTime = new GameTime(elapsedTime, totalTime); }
protected void Update(GameTime gameTime) { _intervalCount++; // Update objects. }