Provides a persistent object that maintains consistent delta timings which can be accessed from a global variable:
global.dt_steady (variable can easily be changed to a preferred naming convention)
// Move right 100 pixels every 1 second pixelsPerSecond = 100; x += pixelsPerSecond * global.dt_steady; // Add 2 to health each second healthPerSecond = 2; health = health + (healthPerSecond * global.dt_steady); // Set number of sprite images to play per second imagesPerSecond = 10; image_speed = imagesPerSecond * global.dt_steady; // Turn 45 degrees every second direction += 45 * global.dt_steady; // Update seconds timer timerSeconds += global.dt_steady;
Also provided is a way to set the delta time scale, allowing you to easily create global slow/fast motion effects for all values affected by delta timing.
obj_SteadyDeltaTime.scale = 0.0; // "Pause" obj_SteadyDeltaTime.scale = 0.5; // Half speed obj_SteadyDeltaTime.scale = 1.0; // Normal speed obj_SteadyDeltaTime.scale = 2.0; // Double speed
Be sure to check out some of my other assets!
Improved file organisation for GMS 2.3 and updated included example.