Skip to content

time

FreeBodyEngine.core.time #

CooldownManager() #

Bases: Service

Tracks the remaining time on every active @cooldown/@physics_cooldown-decorated call, keyed by id(self) of the instance the decorated method was called on.

Sets up empty cooldown-tracking dicts for both the frame-time and physics-time decorators.

cooldowns = {} instance-attribute #

physics_cooldowns = {} instance-attribute #

on_destroy() #

Unregisters update() and physics_update() from their update phases.

on_initialize() #

Registers update() and physics_update() to run every frame's UPDATE phase and every physics step, respectively.

physics_update() #

Counts down every tracked @physics_cooldown entry by one physics step's delta time.

update() #

Counts down every tracked @cooldown entry by this frame's delta time.

Time() #

Tracks wall-clock delta time, elapsed time, and frame/tick rates for the engine's main loop (see UpdateCoordinator in core/update.py, which drives update()/tick()/frame()).

Starts the clock and zeroes all timing/counter state.

delta_time = 0.0 instance-attribute #

frame_count = 0 instance-attribute #

time_scale = 1.0 instance-attribute #

total_time = 0.0 instance-attribute #

unscaled_delta_time = 0.0 instance-attribute #

frame() #

Records that a frame was just rendered, for get_fps() - call once per rendered frame.

get_fps() #

Returns the number of frames rendered in the last second (see frame()).

get_time() #

Returns the total time elapsed since this Time was created, in seconds.

get_tps() #

Returns the number of physics ticks run in the last second (see tick()).

tick() #

Records that a physics tick was just run, for get_tps() - call once per physics step.

update() #

Advances the clock by one main-loop iteration: recomputes delta_time (scaled by time_scale and clamped to 0.1s, so a long stall - a debugger break, a slow load - can't make a single step simulate more than 0.1 simulated seconds) and unscaled_delta_time, and warns if the step took unusually long.

cooldown(seconds) #

Decorator to add a cooldown to functions.

physics_cooldown(seconds) #

Decorator to add a cooldown to physics based functions.