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 ...

Get Beginning C++ Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.