DeltaTimer - GameMaker Studio

Frame-Based Timing for GameMaker Studio

Scripts that will allow you to use frame-based timing in GameMaker Studio.

The scripts can setup timing inside an existing object. You simply do:

  1. Add r2d_dtCreate in the Create event
  2. Add r2d_dtBeginStep in the Begin Step event
  3. Call the r2d_dtXXX functions to update your objects or directly use global.r2d_DeltaTimer

Set global.r2d_dtDesiredFPS (default is 30) to set the speed of your simulation. Set global.r2d_dtMinFPS (default 10) to set the minimum FPS to try and maintain your desired simulation speed. Anything below this minimum value will just fall through.

global.r2d_dtMinFPS = 10; // manage simulation down to this speed
global.r2d_dtDesiredFPS = 60; // keep simulation running at this speed

r2d_dtCreate will set GMS's internal game fps to a very high value to prevent GMS from trying to lock the framerate. r2d_dtBeginStep has support to prevent large spikes in speed caused by background tasks. The end result is that you will have now decoupled rendering from updating, allowing your simulation to run at a known and predictable rate.