Time
Functions for managing time and frame rate.
Get Delta
get_delta() → floatGet the time elapsed since the last frame.
Returns
float : The delta time in seconds.
Note:
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. This will not, however, clamp the value returned by get_fps().
Get FPS
get_fps() → floatGet the current frames per second (FPS) measurement.
Returns
float : The current FPS value.
Set Target
set_target(frame_rate: int) → NoneSet the target frame rate for the application.
Parameters
frame_rate: The desired frame rate in frames per second (FPS). Values ≤ 0 disable frame rate limiting.
Get Elapsed
get_elapsed() → floatGet the total elapsed time since the application started.
Returns
float : The elapsed time in seconds.
Delay
delay(ms: float) → NonePause the application for a specified duration.
Parameters
ms: The amount of time to delay in milliseconds.
Note:
This function pauses execution for the given number of milliseconds — useful for simple timing control.
Though, set_target() is generally preferred for precise frame rate control with nanosecond accuracy.
Set Max Delta
set_max_delta(max_delta: float) → NoneSet the maximum allowed delta time between frames.
Parameters
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: float) → NoneSet the global time scale factor.
Parameters
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
get_scale() → floatGet the current global time scale factor.
Returns
float : The current time scale factor.