Book Image

SFML Blueprints

Book Image

SFML Blueprints

Overview of this book

Table of Contents (15 chapters)
SFML Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Turning our application to an Asteroid clone


Asteroid is an arcade "shoot 'em up" game created in 1979 by Atari Inc., and is considered a classic. The player controls a spaceship in an asteroid field with some flying saucers appearing on the screen from time to time, attacking it. The goal of this game is to destroy all the asteroids and saucers by shooting at them. Each level increases the number of asteroids in the field, and the game becomes harder and harder.

To build this game, we will use our actual application as a base, but we need to add a lot of things to it.

The Player class

The player is represented as a spaceship. The spaceship has the ability to rotate left and right, to shoot, and the spaceship can also give itself a boost. The player can also send the ship into hyperspace, causing it to disappear and reappear in a random location on the screen, at the risk of self-destructing or appearing on top of an asteroid.

The player starts with three lives, and on every 10,000 points,...