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 ...
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.