Time related functions
get_delta() → floatget_delta() → floatGet the time elapsed since the last frame in seconds.
For stability, the returned delta is clamped so it will not be smaller than 1/12 seconds (equivalent to capping at 12 FPS). This prevents unstable calculations that rely on delta when very small frame times are measured.
Returns
float : The time elapsed since the last frame, in seconds.
set_max_delta(max_delta: float) → Noneset_max_delta(max_delta: float) → NoneSet the maximum allowed delta time between frames.
Args
max_delta : Maximum delta time in seconds (> 0.0).
Use this to avoid large deltas during frame drops or pauses
that could destabilize physics or animations.get_fps() → floatget_fps() → floatGet the current frames per second of the program.
Returns
float : The current FPS based on the last frame time.
set_target(frame_rate: int) → Noneset_target(frame_rate: int) → NoneSet the target framerate for the application.
Args
frame_rate : Target framerate to enforce. Values <= 0 disable frame rate limiting.get_elapsed() → floatget_elapsed() → floatGet the elapsed time since the program started.
Returns
float : The total elapsed time since program start, in seconds.
delay(milliseconds: int) → Nonedelay(milliseconds: int) → NoneDelay the program execution for the specified duration.
This function pauses execution for the given number of milliseconds. Useful for simple timing control, though using time.set_cap() is generally preferred for precise frame rate control with nanosecond accuracy.
Args
milliseconds : The number of milliseconds to delay.set_scale(scale: float) → Noneset_scale(scale: float) → NoneSet the global time scale factor.
Args
scale : The time scale factor. Values < 0.0 are clamped to 0.0.
A scale of 1.0 represents normal time, 0.5 is half speed,
and 2.0 is double speed.get_scale() → floatget_scale() → floatGet the current global time scale factor.
Returns
float : The current time scale factor.