Skip to content

main

FreeBodyEngine.core.main #

Main() #

The engine's top-level singleton - owns global flags, timing, the update-loop coordinator, and the service locator, and drives the main loop via run(). Constructing one registers it as the module-level "main object" (FreeBodyEngine._set_main), which is what fb.get_main()/fb.get_service()/etc. all resolve against.

Sets up flags (seeded from any fb.set_flag() calls made before the engine existed), timing, the update coordinator, and the service locator, and registers itself as the global Main instance. Also wires the QUIT event to self.quit, so fb.fbquit()/emitting QUIT stops the main loop.

flags = GlobalFlags(pre_flags) instance-attribute #

running = True instance-attribute #

services = ServiceLocator() instance-attribute #

time = Time() instance-attribute #

updater = UpdateCoordinator(self.time) instance-attribute #

quit() #

Stops the main loop after its current iteration finishes.

run() #

Runs the engine's main loop until quit() is called: advances time and drives every registered update phase through self.updater each iteration. Wraps each iteration in a Profiler start/stop if the PROFILER flag is set.

Under Pyodide (sys.platform == "emscripten" - a browser tab, see utils.get_platform()'s docstring) this delegates to _run_web() instead of looping here directly - see that method for why a blocking while loop is fundamentally incompatible with a browser tab at all, not just a style difference.