Using the background
We have done the tricky stuff, this will be simple. There are three steps:
Create a
VertexArray
.Initialize it after leveling up each wave.
Draw it in each frame.
Add the code highlighted in the following to declare a VertexArray
called background
and load the background_sheet.png
as a texture:
// Create an instance of the Player class
Player player;
// The boundaries of the arena
IntRect arena;
// Create the backgroundVertexArray 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 in the highlighted code that we have also modified the way that we initialize the tileSize
variable. Add the highlighted code exactly as shown:
if...