Building the LevelManager class
It will take several phases of coding to make our level designs work. The first thing we will do is code the LevelManager
header file. This will allow us to look at and discuss the member variables and functions that will be in the LevelManger
class.
Next, we will code the LevelManager.cpp
file, which will have all the function definitions in it. As this is a long file, we will break it up into several sections, to code and discuss them.
Once the LevelManager
class is complete, we will add an instance of it to the game engine (Engine
class). We will also add a new function to the Engine
class, loadLevel
, which we can call from the update
function whenever a new level is required. The loadLevel
function will not only use the LevelManager
instance to load the appropriate level but it will also take care of aspects such as spawning the player characters and preparing the clock.
As already mentioned, let's get an overview of LevelManager
by coding the LevelManager...