In the main.cpp class, include the Enemy header file. Since we want more than one enemy instance, we need to add a vector called enemies and then add all the newly-created enemies to it.
In the context of the following code, the vector phrase has absolutely nothing to do with math, but rather with a list of objects. In fact, it is like an array in which we can store multiple objects. Vectors are used instead of an array because vectors are dynamic in nature, so it makes it easier to add and remove objects from the list (unlike an array, which, by comparison, is a static list). Let's get started:
- We need to include <vector> in the main.cpp file, as follows:
#include "SFML-2.5.1\include\SFML\Graphics.hpp" #include <vector> #include "Hero.h" #include "Enemy.h"
- Next, add a new variable called enemies of the vector...