Updating the game engine to use Thomas and Bob
In order to be able to run the game and see our new characters, we have to declare instances of them, call their spawn
functions, update them each frame, and draw them each frame. Let's do that now.
Updating Engine.h to add an instance of Bob and Thomas
Open up the Engine.h
file and add the highlighted lines of code, as shown in the following:
#pragma once #include <SFML/Graphics.hpp> #include "TextureHolder.h" #include "Thomas.h" #include "Bob.h" using namespace sf; class Engine { private: // The texture holder TextureHolder th; // Thomas and his friend, Bob Thomas m_Thomas; Bob m_Bob; const int TILE_SIZE = 50; const int VERTS_IN_QUAD = 4; ... ...
Now we have an instance of both Thomas
and Bob
, which ...
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.