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

Colliding Objects

Now that we know what is required to define a collision, let’s create one in a simple program. The following program contains two simple objects: a sphere that will be our player that we move and a cone that will be the object we smash into. Open the file demo11-01.bb or enter the following code:

;demo11-01.bb - Collisions ; ———————————————— Graphics3D 640,480 SetBuffer BackBuffer() Const ESC_KEY = 1 Const LEFT_KEY = 203 Const RIGHT_KEY = 205 Const UP_KEY = 200 Const DOWN_KEY = 208 camera=CreateCamera() ; Creating a light light=CreateLight() ; Creating a sphere sphere=CreateSphere() ScaleEntity sphere, 0.5,0.5,0.5 PositionEntity sphere, -3,0,5 ; Creating a cone cone=CreateCone() PositionEntity cone, 1,0,5 ScaleEntity cone, 1.5,1.5,1.5 ...

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