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.
The code that we entered basically says that when the space bar is pressed, turn off the collisions. Go ahead and run the program now. You’ll see that you can still move around the object, but as soon as you press the space bar, collisions will be turned off. What if you wanted the ability to turn collisions on and off as you please? Here we will add code that will turn the collisions on again when you press the number 1.
If KeyDown( 200 )=True Then y#=0.1 MoveEntity sphere,x#,y#,z# While KeyHit( 57 ) ClearCollisions Wend While KeyHit( 2) Collisions type_player,type_obstacle,2,2 Wend UpdateWorld RenderWorld Flip Wend End
Note
Another collision you’ll typically want to add is one with the terrain and one with the sky so that your players don’t fall through the terrain or over the edge.
3.14.246.207