Building a horde of zombies
Now, we are armed with the TextureHolder
class to make sure that our zombie textures are easily available as well as only loaded into the GPU once. Then, we can investigate creating a whole horde of them.
We will store zombies in an array. Since the process of building and spawning a horde of zombies involves quite a few lines of code, it is a good candidate for abstracting to a separate function. Soon, we will code the CreateHorde
function but first, of course, we need a Zombie
class.
Coding the Zombie.h file
The first step to building a class to represent a zombie is to code the member variables and function prototypes in a header file.
Right-click Header Files in the Solution Explorer and select Add | New Item.... In the Add New Item window, highlight (by left-clicking) Header File (.h), and then in the Name field, type Zombie.h
.
Add the following code to the Zombie.h
file:
#pragma once
#include <SFML/Graphics.hpp>
using...