Using the Pickup class
After all that hard work implementing the Pickup
class, we can now go ahead and write code in the game engine to put some pickups into the game.
The first thing we will do is add an include directive to the ZombieArena.cpp
file:
#include <SFML/Graphics.hpp> #include "ZombieArena.h" #include "Player.h" #include "TextureHolder.h" #include "Bullet.h" #include "Pickup.h" using namespace sf;
In this following code, we are adding two Pickup
instances: one called healthPickup
and another called ammoPickup
. We pass the values 1 and 2, respectively, into the constructor so that they are initialized to the correct type of pickup. Add the following highlighted code, which we have just discussed:
// Hide the mouse pointer and replace it with crosshair window.setMouseCursorVisible(true); Sprite spriteCrosshair; Texture textureCrosshair = TextureHolder::GetTexture( ...