Using the background
We have done the tricky stuff, 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.
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 the createBackground function, passing in background as a reference and arena by value. Notice that, in the highlighted code, we have also modified the way that we initialize the tileSize variable. Add the highlighted code exactly as shown: