October 2016
Beginner
520 pages
10h 19m
English
After all that hard work implementing the Pickup class, we can now go ahead and write code in the game engine to actually put some pickups into the game.
The first thing we do is add an include directive to the ZombieArena.cpp file:
#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include "ZombieArena.h"
#include "Player.h"
#include "TextureHolder.h"
#include "Bullet.h"
#include "Pickup.h"
using namespace sf;In the following code, we add two Pickup instances, one called healthPickup and the other 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 highlighted code we have just discussed:
// Hide the mouse pointer and replace it ...
Read now
Unlock full access