Book Image

Android Game Programming by Example

By : John Horton
Book Image

Android Game Programming by Example

By: John Horton

Overview of this book

Table of Contents (18 chapters)
Android Game Programming by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
7
Platformer – Guns, Life, Money, and the Enemy
Index

Planning for collision detection


What we are trying to achieve can be put into the following two categories:

  • What we want for the border:

    • Asteroids, bullets, and the ship need to know when they have collided with the border

    • Asteroids should reverse and head back into the game area when they touch the border

    • A bullet should reset itself at the border

    • The ship should subtract a life and then respawn in the centre

  • What we want for the asteroids. We need to know and respond when:

    • The ship touches an asteroid

    • When a bullet touches an asteroid

    • As in the original Asteroids game, we will not respond to asteroids bumping into each other

Although we will not be detecting an asteroid on asteroid collisions, you will see that when our collision detection nears completion, achieving asteroid on asteroid collision detection will not present much of an extra challenge. However, it will put extra strain on the device's CPU.

We know that we have object on border collisions to detect and object on asteroid collisions...