Chapter 4. Collision Detection

In most games we need to detect when objects intersect with each other to trigger actions; this is called collision detection. We will use it to detect when a bullet hits an asteroid (to destroy it) and when the player is hit by an asteroid (to end the game). This detection can be done in a discrete or in a continuous way, and it can involve different types of shapes. We will use discrete detection with rectangular and circular shapes.

As mentioned in Chapter 1, Setting Up the Project, we are not going to do any Physics simulation. That is a completely separate topic and it is long enough to deserve its own book.

We will also discuss optimization techniques and implement one method called spatial partitioning that ...

Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.