From c649b24dad853511e9ef10be4f30e0c0ea990e2e Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 11 Aug 2022 21:55:12 -0700 Subject: [PATCH] Game.Timestep is now public --- src/Game.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Game.cs b/src/Game.cs index 9cdb67a6..12a453a5 100644 --- a/src/Game.cs +++ b/src/Game.cs @@ -12,11 +12,10 @@ namespace MoonWorks public abstract class Game { public TimeSpan MAX_DELTA_TIME = TimeSpan.FromMilliseconds(100); + public TimeSpan Timestep { get; private set; } private bool quit = false; - private Stopwatch gameTimer; - private TimeSpan timestep; private long previousTicks = 0; TimeSpan accumulatedUpdateTime = TimeSpan.Zero; TimeSpan accumulatedDrawTime = TimeSpan.Zero; @@ -51,7 +50,7 @@ namespace MoonWorks bool debugMode = false ) { - timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep); + Timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep); gameTimer = Stopwatch.StartNew(); FramerateCapped = framerateSettings.Mode == FramerateMode.Capped; @@ -159,17 +158,17 @@ namespace MoonWorks if (!quit) { - while (accumulatedUpdateTime >= timestep) + while (accumulatedUpdateTime >= Timestep) { Inputs.Update(); AudioDevice.Update(); - Update(timestep); + Update(Timestep); - accumulatedUpdateTime -= timestep; + accumulatedUpdateTime -= Timestep; } - var alpha = accumulatedUpdateTime / timestep; + var alpha = accumulatedUpdateTime / Timestep; Draw(alpha); accumulatedDrawTime -= FramerateCapTimeSpan;