Time
Time related functions
Delay
delay(milliseconds: SupportsInt) → 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.
Get Delta
get_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.
Get Elapsed
get_elapsed() → floatGet the elapsed time since the program started.
Returns
float : The total elapsed time since program start, in seconds.
Get Fps
get_fps() → floatGet the current frames per second of the program.
Returns
float : The current FPS based on the last frame time.
Get Scale
get_scale() → floatGet the current global time scale factor.
Returns
float : The current time scale factor.
Set Max Delta
set_max_delta(max_delta: SupportsFloat) → 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.
Set Scale
set_scale(scale: SupportsFloat) → 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.
Set Target
set_target(frame_rate: SupportsInt) → NoneSet the target framerate for the application.
Args
frame_rate: Target framerate to enforce. Values <= 0 disable frame rate limiting.