Class GameLoopExtensions
Settings for the game loop itself, as opposed to what is in the scene.
public static class GameLoopExtensions
- Inheritance
-
GameLoopExtensions
Methods
SetDeterministic(Game, TimeSpan?)
Pins the game loop so that frame N is the same simulated instant on every machine and every run: a fixed timestep, draws in step with updates, and exactly one update per draw. What a replay, a lockstep game, a test or a screenshot wants; not what a game that should feel smooth on a slow machine wants, since a late frame is no longer caught up by extra updates.
public static void SetDeterministic(this Game game, TimeSpan? step = null)
Parameters
gameGameThe game to pin.
stepTimeSpan?The fixed step; left out, the game's current TargetElapsedTime stays.
Remarks
A fixed timestep alone still lets a slow tick - the first frames while shaders compile, or any
run on a software renderer - run two or more updates before one draw to catch up, so frame N
would sit at a different simulated time from one run to the next. One update per draw is the
setting that pins it, and it is protected internal on GameBase, which a
plain Game cannot reach; reflection is the honest cost of not subclassing. A test
reads the same property back, so the engine renaming it fails a test rather than silently
un-pinning every golden image.