Using the background
We have done the tricky stuff already, so this will be simple. There are three steps, as follows:
- Create a
VertexArray. - Initialize it after leveling up each wave.
- Draw it in each frame.
Before we add the new code, the ZombieArena.cpp file needs to know about the new ZombieArena.h file. Add the following include directive to the top of the ZombieArena.cpp file:
#include "ZombieArena.h"
Now, add the following highlighted code to declare a VertexArray instance called background and load the background_sheet.png file as a texture:
// Create an instance of the Player class
Player player;
// The boundaries of the arena
IntRect arena;
// Create the background
VertexArray background;
// Load the texture for our background vertex array
Texture textureBackground;
textureBackground.loadFromFile("graphics/background_sheet.png");
// The main game loop
while (window.isOpen())
Add the following code to call...