Managing many "screens"
Posted: Sun Jan 07, 2024 8:25 pm
Hi, newbie here
What would be the best way to handle multiple screens (levels, rooms, scenes, states, whatever you call it) in this engine? I don't mean "screens" as in multiple monitors or splitscreen. I mean
ex.
title-screen
level-select screen
option screen
level-1
level-2
...
credits
I went through most of the tutorial but they show only single-screen applications. This is fine for something small like Tetris or FlappyBird, but I want to make a more advanced game. I want to know how to handle multiple screens. How to transition from screen to screen. How to unload a current screen to load the next one. How to handle transition effects like a screen-fade/wipe. The proper way to load/render a list of enemies, terrain, lights, and whatever other objects for that scene.
My best idea is to make a base class called Screen that contains their own list of entities and variables, and virtual methods "OnEntry/OnExit/onFrameTick". This seems like what popular game engines do. OnEntry/OnExit would be called when a screen changes (likely through my own ScreenManager class) and onFrameTick is the logic and render that gets called every frame for that screen only.
I am unsure whether Irrlicht already fulfills this sort of functionality. Particularly I'm confused by the existence of the "ISceneManager". After all it is what I need to basically use what irrlicht has to offer (models, camera, etc, which all inherit ISceneNode and get added to the ISceneManager).
So my question is how/when am I supposed to use ISceneManager? Would it be best to make my own Screen class which contains an ISceneManager pointer? I would load all ISceneNodes into the scenemanager inside "onEntry" (or whenever I initialize the screen). Then inside "onFrameTick" I would simply call scenemanager->drawAll(). Does that seem correct? Is it necessary to clear() whenever I want to change screens ("onExit"), or do I simply stop calling the draw function?
What would be the best way to handle multiple screens (levels, rooms, scenes, states, whatever you call it) in this engine? I don't mean "screens" as in multiple monitors or splitscreen. I mean
ex.
title-screen
level-select screen
option screen
level-1
level-2
...
credits
I went through most of the tutorial but they show only single-screen applications. This is fine for something small like Tetris or FlappyBird, but I want to make a more advanced game. I want to know how to handle multiple screens. How to transition from screen to screen. How to unload a current screen to load the next one. How to handle transition effects like a screen-fade/wipe. The proper way to load/render a list of enemies, terrain, lights, and whatever other objects for that scene.
My best idea is to make a base class called Screen that contains their own list of entities and variables, and virtual methods "OnEntry/OnExit/onFrameTick". This seems like what popular game engines do. OnEntry/OnExit would be called when a screen changes (likely through my own ScreenManager class) and onFrameTick is the logic and render that gets called every frame for that screen only.
I am unsure whether Irrlicht already fulfills this sort of functionality. Particularly I'm confused by the existence of the "ISceneManager". After all it is what I need to basically use what irrlicht has to offer (models, camera, etc, which all inherit ISceneNode and get added to the ISceneManager).
So my question is how/when am I supposed to use ISceneManager? Would it be best to make my own Screen class which contains an ISceneManager pointer? I would load all ISceneNodes into the scenemanager inside "onEntry" (or whenever I initialize the screen). Then inside "onFrameTick" I would simply call scenemanager->drawAll(). Does that seem correct? Is it necessary to clear() whenever I want to change screens ("onExit"), or do I simply stop calling the draw function?