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

Shields Down!—Clear Collisions

You can remove the Collisions command permanently or temporarily using the ClearCollisions command.

Demo11-04.bb looks like the following:

; This following code makes our program run
While Not KeyDown(ESC_KEY)
      x#=0
      y#=0
      z#=0
      If KeyDown(LEFT_KEY)=True Then x#=-0.1
      If KeyDown(RIGHT_KEY)=True Then x#=0.1
      If KeyDown(DOWN_KEY)=True Then y#=-0.1
      If KeyDown(UP_KEY)=True Then y#=0.1
      MoveEntity sphere,x#,y#,z#
      While KeyHit( 57 )
       ClearCollisions
      Wend

      RenderWorld
      UpdateWorld
      Flip
Wend

Run the program now, and when you press the space bar, the collisions are cleared, as in Figure 11.7.

Figure 11.7. Once the space bar is pressed in demo11-04.bb, the collisions are cleared and the sphere can once again go through the cone.

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