home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
3D Game Programming for Teens (2nd Edition)
/
3DGPFT2E.iso
/
Source
/
Chapter11
/
demo11-06.bb
< prev
next >
Wrap
Text File
|
2009-01-20
|
1KB
|
83 lines
;demo11-06.bb - Hiding on collision
;_______________
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
; Create camera
camera=CreateCamera()
; Creating a light
light=CreateLight()
; Creating the types
type_player=1
type_obstacle=2
; Creating a sphere
sphere=CreateSphere()
ScaleEntity sphere, 0.5,0.5,0.5
PositionEntity sphere, -3,0,5
EntityType sphere,type_player
EntityRadius sphere, 0.2
; Creating a cone
cone=CreateCone()
PositionEntity cone, 1,-1,5
ScaleEntity cone, 1.5,1.5,1.5
EntityType cone,type_obstacle
Collisions type_player,type_obstacle,2,2
; Creating a cone
cone1=CreateCone()
PositionEntity cone1, 1,2,5
ScaleEntity cone1, 1.5,1.5,1.5
EntityType cone1,type_obstacle
Collisions type_player,type_obstacle,2,2
; 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
If CountCollisions (sphere)
crash=CollisionEntity (sphere,1)
HideEntity crash
EndIf
MoveEntity sphere,x#,y#,z#
UpdateWorld
RenderWorld
Flip
Wend
End