time
pykraken.time Time related functions
At a glance
8 membersReference
PYTHON APIdelay
functiondelay(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 (
int) — The number of milliseconds to delay.
get_delta
functionget_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
functionget_elapsed() -> floatGet the elapsed time since the program started.
Returns
- float — The total elapsed time since program start, in seconds.
get_fps
functionget_fps() -> floatGet the current frames per second of the program.
Returns
- float — The current FPS based on the last frame time.
get_scale
functionget_scale() -> floatGet the current global time scale factor.
Returns
- float — The current time scale factor.
set_max_delta
functionset_max_delta(max_delta: float) -> NoneSet the maximum allowed delta time between frames.
Args
- max_delta (
float) — 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
functionset_scale(scale: float) -> NoneSet the global time scale factor.
Args
- scale (
float) — 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
functionset_target(frame_rate: int) -> NoneSet the target framerate for the application.
Args
- frame_rate (
int) — Target framerate to enforce. Values <= 0 disable frame rate limiting.