Documentation Index
Fetch the complete documentation index at: https://mintlify.com/VKSFY/keel/llms.txt
Use this file to discover all available pages before exploring further.
App is the single object you construct at the top of every Keel game. It initialises a GLFW window, creates a World, wires all input callbacks, and owns the Scheduler that drives the game loop. Call app.run() to block until the window closes; everything else — registering systems, inserting resources, loading assets — happens before that call.
Constructor
Text shown in the OS window title bar.
Initial framebuffer width in pixels.
Initial framebuffer height in pixels.
Enable GLFW swap-interval V-Sync. When
False, the loop inserts a manual sleep to target FIXED_DT frame time instead of relying on the display sync.Create InputState
Instantiates
InputState() and registers it as a world resource so systems can receive it via dependency injection.Properties
App.world
World instance. Spawn entities, register components, query, and emit events through this object. Systems registered with @app.system receive this as their first argument.
App.input
InputState polling object. Use it outside of a system for one-off checks, or receive it via resource injection inside a system. The same object is registered as a world resource under the InputState type.
App.ctx
moderngl.Context created by the window. Pass this to renderer setup calls that need a GL context reference. The property delegates to app.window.ctx.
App.scheduler
Scheduler that the run loop drives. App and World share the same scheduler instance — @app.system(...) and @world.system(...) both register into it, so there is no duplication or ordering mismatch.
Methods
App.system(phase, after=None)
Decorator factory that registers a function as a system in the given Phase.
The execution phase. One of
Phase.PRE_UPDATE, UPDATE, POST_UPDATE, PRE_RENDER, RENDER, POST_RENDER.A system function (or list of functions) that must run before this one within the same phase. Raises
ValueError if any listed function is in a different phase or does not exist.world and dt. The scheduler resolves them from the world’s resource map by type annotation:
App.insert_resource(resource, type_=None)
Register a singleton resource that systems can receive via dependency injection.
Any Python object to store as a singleton.
Override the key type used for look-up. When omitted,
type(resource) is used. Pass an explicit type when registering a subclass instance that should be retrieved by its base class.App.setup_assets(watch_dirs=None)
Create and return the AssetRegistry, registering default loaders and (optionally) a hot-reload file watcher.
List of filesystem directories to watch for changes. When a file changes, the asset is reloaded automatically during
PRE_UPDATE.The configured asset registry, also registered as a world resource.
App.add_shutdown_hook(hook)
Register a callable to invoke after the main loop exits and before GLFW is torn down.
Zero-argument callable. Exceptions raised inside the hook are swallowed so that subsequent hooks and GLFW cleanup still run.
App.run()
Block until the window closes, then invoke shutdown hooks, destroy the window, and terminate GLFW.
FixedStepDriver to advance simulation phases at exactly FIXED_DT (1/60 s) and render phases once per visual frame. See Phase for the execution model.
keel.FIXED_DT
PRE_UPDATE, UPDATE, POST_UPDATE) always receive this exact value as dt. Render phases receive the real elapsed wall-clock time for the frame.
keel.dev_tools(app)
DevTools bundle for app. Call after app.setup_assets() and physics setup so the inspector and debug-draw systems can see all registered resources.
The
App instance to attach developer tooling to.The
DevTools bundle with profiler, debug_draw, and inspector attached.dev_tools twice on the same App returns the cached instance — the systems are not registered twice.
DevTools
DevTools is a simple container created by keel.dev_tools(app). It registers three debug subsystems as world resources and in the appropriate render phases.
profiler
A frame profiler that wraps every system call in
begin/end timing markers. Access via tools.profiler.debug_draw
An overlay that draws physics collider outlines using GL lines. Only set when a
Physics2D resource exists; otherwise None. Access via tools.debug_draw.inspector
An ImGui-based entity inspector panel. Renders on top of the debug-draw overlay in
POST_RENDER. Access via tools.inspector.debug_draw is None when no Physics2D resource is found. Attach physics before calling dev_tools if you want collision shape overlays.