Skip to content

update

FreeBodyEngine.core.update #

UpdateCoordinator(time) #

Drives the main loop's fixed-timestep physics updates and framerate- capped update/draw updates, dispatching to callbacks registered per UpdatePhase (see FreeBodyEngine.register_service_update).

Derives the physics/update timesteps from the MAX_TPS/MAX_FPS flags (defaulting to 69 each) and starts with no callbacks registered for any phase.

physics_accumulator = 0 instance-attribute #

physics_timestep = 1 / get_flag(MAX_TPS, 69) instance-attribute #

time = time instance-attribute #

update_accumulator = 0 instance-attribute #

update_timestep = 1 / get_flag(MAX_FPS, 69) instance-attribute #

register(phase, callback, priority=0) #

Registers callback to run during phase, ordered by priority (highest first) among other callbacks in the same phase.

unregister(phase, callback) #

Removes callback from phase's registered callbacks.

update() #

Advances the loop by one iteration: runs EARLY callbacks once, then PHYSICS callbacks as many times as physics_timestep fits into the accumulated delta time (ticking self.time after each), then - once a full update_timestep has accumulated - UPDATE then DRAW callbacks a single time (advancing self.time's frame counter), then LATE callbacks once. Each callback runs through _run(), so one raising doesn't stop the rest from running this frame, or any future frame.

UpdatePhase #

Bases: Enum

The phases a callback can hook into via FreeBodyEngine.register_service_update, run in this order by UpdateCoordinator.update() on every main-loop iteration: EARLY (always once), PHYSICS (zero or more times, at a fixed timestep), UPDATE then DRAW (at most once, throttled to the update timestep), LATE (always once).

DRAW = auto() class-attribute instance-attribute #

EARLY = auto() class-attribute instance-attribute #

LATE = auto() class-attribute instance-attribute #

PHYSICS = auto() class-attribute instance-attribute #

UPDATE = auto() class-attribute instance-attribute #