Studio › Manual › Code and objects

Delta time and timers

Studio adds time in seconds, so a game moves at the same speed at 60, 90 or 120 frames a second:

  • dt: seconds since the last step (0.016667 at 60 fps), at most 0.1. pos += vel * dt;
  • time_scale: slow motion or fast forward for the whole game (0 pauses), or for one instance (its own time_scale). dt is already scaled.
  • dt_unscaled, time_now, time_now_unscaled: for menus and UI that keep going in slow motion or pause.
  • Timers in seconds: timer_after(0.5, fn), timer_every(1, fn), timer_cancel(t), timer_exists(t), timer_get_time_left(t).
  • A fixed-rate step for physics: fixed_step_enable(60) runs User Event 15 at that rate; physics_dt, fixed_step_alpha.

A project's own variable called dt stays its own. In GameMaker builds a small script and object Studio adds to the build's copy work out dt, time_scale and the timers from GameMaker's delta_time each step.

Keys are shown as on the Mac: ⌘ Command, ⌥ Option, ⌃ Control, ⇧ Shift. Studio for Windows shows its own keys beside each menu item.