Creating a randomly generated scrolling background
In this section, we will create a function that makes a background in a separate file. We will ensure the background will be available (in scope) to the main
function by using a vertex array reference.
As we will be writing other functions that share data with the main
function, we will write them all in their own .cpp
files. We will provide prototypes for these functions in a new header file that we will include (with an #include
directive) in ZombieArena.cpp
.
To achieve this, let's make a new header file called ZombieArena.h
. We are now ready to code the header file for our new function.
In this new ZombieArena.h
header file, add the following highlighted code, including the function prototype:
#pragma once using namespace sf; int createBackground(VertexArray& rVA, IntRect arena);
The previous code allows us to write the definition of a function called createBackground
. To match the prototype, the function...