Book Image

Mastering Android Game Development

By : Raul Portales
Book Image

Mastering Android Game Development

By: Raul Portales

Overview of this book

Table of Contents (18 chapters)
Mastering Android Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
API Levels for Android Versions
Index

Detecting collisions


There are two main approaches to checking collisions:

  • Discrete, or a posteriori

  • Continuous, or a priori

For the discrete approach, we advance the state of the game items and then check if any of them are intersecting. It is a discrete simulation because we only do the evaluation at the end of each step. It is called a posteriori because it is done after the objects have moved. It is reactive. Most of the time we lack the exact point of contact; we only know that at the end of the simulation step the objects are colliding.

On the other hand, a continuous approach predicts the collision before applying the movement, based on the parameters of each object. It is calculated before the movement is performed. That's why it is called a priori. This method provides the exact point of contact and it is extremely useful when we require precision—such as for physics simulation.

The discrete method is generally one dimension simpler than the continuous one. This makes it much easier...