From c08defc6568fa4fd52f1034377ba9cbd7ad6f802 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 11 Mar 2020 11:12:14 -0400 Subject: [PATCH] Keep Update() from advancing by very large chunks; use more double math --- Shared/SneakGame.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Shared/SneakGame.cs b/Shared/SneakGame.cs index d593544..f3dc04a 100644 --- a/Shared/SneakGame.cs +++ b/Shared/SneakGame.cs @@ -107,9 +107,11 @@ namespace SemiColinGames { } if (!paused) { - float modelTime = (float) gameTime.ElapsedGameTime.TotalSeconds; + double modelTime = gameTime.ElapsedGameTime.TotalSeconds; + // To prevent huge diffs, never update by more than 4 frames' worth of time. + modelTime = Math.Min(modelTime, TARGET_FRAME_TIME * 4.0f); Clock.AddModelTime(modelTime); - world.Update(modelTime, input); + world.Update((float) modelTime, input); } base.Update(gameTime);