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 are derived from PlayableCharacter
.
Updating the input function to control Thomas and Bob
Now we will add the ability to control the two characters. This code...