Steady Delta Time

Steady Delta Time LogoGet it on the GameMaker: Marketplace

Provides a persistent object that maintains predictable delta timings which can be accessed from a global variable:

global.dt_steady (variable can easily be changed to a preferred naming convention)

Documentation can be found inside the Create Event of obj_SteadyDeltaTime

[Examples]

// 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

 

Leave a Reply