Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Extending the ship class


Now that the base of our ship class is done, let's think of what we need for the ship class:

  • Hit points: If a ship is hit, the hit points should reflect this state. The ship will start out with a given number of hit points, say 20 for example, and it will lose some each time it is hit. When it finally reaches zero hit points, it will be completely destroyed.

  • Direction: This is the direction the ship is facing. Depending on the direction, the cannonballs will be fired from each side of the ship.

We should abstain from using filenames where we don't necessarily need to, for example now, when initializing our ship instances.

Before we go ahead and get to the coding part of things, let's download the latest images from https://github.com/freezedev/pirategame-assets/releases/download/0.6/Graphics_06.zip. These images include updated sprite sheets for both the pirate ship and a cannonball that we will use later.

Delete the ship_small_cannon files and copy the newer files...