o
odinpkg.dev
packages / library / scenes

scenes

7ace574library

Scene management system for Odin + raylib

MIT · updated 2 months ago

scenes

A scene management system for Odin + raylib.

A scene is defined by a rawptr to the scene's state, and 4 procedures that take it as a parameter:

  • init is called the start
  • update is called every frame
  • render is called every frame after update, and happens between BeginDrawing and EndDrawing procedures
  • cleanup is called when the scene is closed, after render Since the data is defined as rawptr, you can set the data field to anything. You can even have shared data between all scenes.

To run the system, call the run procedure. The system is based on a stack. This means that you can have open new scenes without the cleanup of the previous ones. When set_scene is called, the whole stack is replaced, and only the new scene remains. When push_scene is called, the scene is pushed on top of the stack. Once the stack is empty, the run procedure returns.

Since scenes are mostly a collection of procedures, you can declare them as constants, and assign data to them using with_data procedure.

To use this library, clone this repository and copy the scenes directory to your project

To run the demo, run the following command

odin run .