Asteroid slalom

It's now time to implement the final feature of this chapter. We are going to implement a slalom race with a twist. In a typical slalom, the point is to race around each obstacle without touching it. To keep things simple, we are going to race through each asteroid. If you successfully pass through each asteroid, you win the race.

Setting up collision detection

In order to determine whether you have passed through an asteroid, we have to implement some 3D collision detection. There are many types of collision detection, but we are going to keep it simple and implement spherical collision detection.

Spherical collision detection is a simple check to see whether the center of two 3D objects are within a certain distance of each other. ...

Get OpenGL Game Development By Example 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.