Beginning C++ Game Programming - Second Edition by John Horton

Beginning C++ Game Programming - Second Edition by John Horton

Author:John Horton
Language: eng
Format: mobi, epub
Publisher: Packt Publishing Pvt Ltd
Published: 2019-10-30T16:00:00+00:00


if (healthPickup.isSpawned())

{

window.draw(healthPickup.getSprite());

}

//Draw the crosshair

window.draw(spriteCrosshair);

}

Now, you can run the game and see the pickups spawn and de-spawn. You can't, however, actually pick them up yet:

Now that we have all the objects in our game, it is a good time to make them interact (collide) with each other.

Detecting collisions

We just need to know when certain objects from our game touch certain other objects. We can then respond to that event in an appropriate manner. In our classes, we have already added functions that will be called when our objects collide. They are as follows:

The Player class has a hit function. We will call it when a zombie collides with the player.

The Zombie class has a hit function. We will call it when a bullet collides with a zombie.

The Pickup class has a gotIt function. We will call it when the player collides with a pickup.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.