Levels and LevelsManager!
- Pablo Narvaja

- Dec 5, 2019
- 1 min read
Until now an application made with llamathrust had to manually load and unload a scene thing I haven't done because of the overhead off doing such task. So I've implemented a way to manage scenes now called level in the engine!
Levels
A level is an abstract or pure virtual class that represent a stage in the game or application like the main menu, a track, a loading screen, etc. The level is the owner of a set of meshes, textures and materials (not to be confused with a shader), is responsible for loading and unloading those assets, to update the state of the game and manage the events.
The class have this look:

As we can see managing the events is optional but no the rest of the responsibilities.
Levels Manager
I needed a way to load levels so a created a singleton class called LevelManager.
The LevelManager is responsible for knowing what are the levels availables and which is the active one as to update it.
There can only be one active level in the whole application so loading a level set it as active. And for the LevelManager to know what levels are availables we need to register the level before loading, this means to have a object of type level created before loading it.
Every level has a name by which we call it.
Here is how the class looks like:

Here is an example I made:

And that's all for this post, folks. Bye!

Comments