O'Reilly logo

3D Game Programming for Teens, Second Edition by Eric Grebler, Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Collisions

Collisions are of utmost importance to our game for several reasons. Using collisions, we’ll have the bullets destroy the targets, we’ll prevent the player from falling through the ground, and we’ll randomly reposition the targets when they hit the ground. We need to identify our collisions, assign a collision type to each object, and then define the collisions. We’ll start with the easy part, identifying the collision types. There are four different groups of collision objects that we will create for this game: the scenery, the bullets, the player, and the gallery items. To define these groups, add the following code in bold:

Graphics3D 1024,768
SetBuffer BackBuffer()

;Setting the type values
type_player=1 type_scenery=2 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required