Time-stepping for Games and Simulations

Previous: Decoupling Refresh Rate from Simulation.

Updated Game View

NickelIron_shotPreviously the TW3GameView was simply trying to issue screen repaints at fixed intervals, what happened if the hardware couldn’t keep up (or could have rendered faster) was your problem.

The new TW3GameView now has several modes:

  • the “VSYNC” mode (just set the Delay to zero), where it will try to refresh the screen as fast as the display can refresh it (and not faster), while minimizing screen tearing
  • the FrameRate mode, where you specify the target frame-rate (in Hz)
  • the old Delay mode, where you specify the delay between frames in milliseconds

Additionally, the view will now automatically suspend repaints if the view goes off-screen (application going to background in a mobile app, tab switch in a browser). I you don’t want that and still want the repaints to occur, just set the AutoPause property to False.

In addition, the overhead of the game view got reduced and the accuracy of frame-rate measurement got improved, and a LastFrameTime provides high-precision measurement for the time since the last frame was rendered.

In terms of Web Standards, the new game view leverages the following APIs:

These API have widespread support, and if not available, the view will automatically fallback to legacy approaches.

Next: Fix Your Steps with a Metronome