scene
This package implements a lightweight scene manager. It streamlines the game loop by mapping directory names to scene enums.
Features:
- Auto-generated enums: The
SceneNameenum from thebonsai:generatedpackage is generated automatically based on directories found in source/game/scenes. - Lifecycle management: Standardized hooks for
init,update,drawandexit. - State persistence: Data is passed between procedures via a
rawptrto a state array. - Simple navigation: Specific
changefunction to handle transitions, changing on the next frame to allow cleanup within theexitfunction.
change
Section titled “change”change :: proc (sceneName: generated.SceneName)Queues a transition to a new scene. The actual transition occurs at the start of the next frame.
draw :: proc ()Calls the draw procedure of the currently active scene.
init :: proc (sceneName: generated.SceneName)Bootstraps the Scene Manager with the starting scene.
Immediately initializes and sets the current scene.
Accepts a SceneName enum as an argument.
update
Section titled “update”update :: proc ()Main update loop for the active scene. Handles the lifecycle of scene transitions automatically.