Using the HUD class

Open Engine.h, add an include for our new class, declare an instance of the new HUD class, and also declare and initialize two new member variables that will keep track of how often we update the HUD. As we have learned in the two previous projects, we don't need to do this for every frame.

Add the highlighted code to Engine.h:

#pragma once 
#include <SFML/Graphics.hpp> 
#include "TextureHolder.h" 
#include "Thomas.h" 
#include "Bob.h" 
#include "LevelManager.h" 
#include "SoundManager.h" 
#include "HUD.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; // Create a SoundManager SoundManager ...

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.