Coding the loadLevel function
To be clear, this function is part of the Engine
class, although it will delegate much of its work to other functions, including those of the LevelManager
class that we just built.
First, let's add the declaration for the new function, along with some other new code, to the Engine.h
file. Open the Engine.h
file and add the highlighted lines of code shown in the following abbreviated snapshot of the Engine.h
file:
#pragma once #include <SFML/Graphics.hpp> #include "TextureHolder.h" #include "Thomas.h" #include "Bob.h" #include "LevelManager.h" using namespace sf; class Engine { private: // The texture holder TextureHolder th; // Thomas and his friend, Bob Thomas m_Thomas; Bob m_Bob; // A class to manage all the levels LevelManager m_LM; const int TILE_SIZE = 50; const int VERTS_IN_QUAD = 4; // The force pushing the characters down const int GRAVITY...