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 m_SM; // The Hud Hud m_Hud; int m_FramesSinceLastHUDUpdate = 0; int m_TargetFramesPerHUDUpdate = 500...