home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming for Teens (2nd Edition) / 3DGPFT2E.iso / Source / Chapter11 / demo11-05.bb < prev    next >
Encoding:
Text File  |  2009-01-21  |  1.1 KB  |  68 lines

  1. ;demo11-05.bb - Hiding on collision
  2. ;_______________
  3.  
  4.  
  5. Graphics3D 640,480
  6. SetBuffer BackBuffer()
  7.  
  8. Const ESC_KEY = 1
  9. Const LEFT_KEY = 203
  10. Const RIGHT_KEY = 205
  11. Const UP_KEY = 200
  12. Const DOWN_KEY = 208
  13.  
  14. ; Create camera
  15. camera=CreateCamera()
  16.  
  17. ; Creating a light
  18.  
  19. light=CreateLight()
  20.  
  21. ; Creating the types
  22.  
  23. type_player=1
  24. type_obstacle=2
  25.  
  26. ; Creating a sphere
  27.  
  28. sphere=CreateSphere()
  29. ScaleEntity sphere, 0.5,0.5,0.5
  30. PositionEntity sphere, -3,0,5
  31. EntityType sphere,type_player
  32. EntityRadius sphere, 0.2
  33.  
  34.  
  35. ; Creating a cone
  36.  
  37. cone=CreateCone()
  38. PositionEntity cone, 1,0,5
  39. ScaleEntity cone, 1.5,1.5,1.5
  40. EntityType cone,type_obstacle
  41.  
  42. Collisions type_player,type_obstacle,2,2
  43.  
  44.  
  45. ; This following code makes our program run
  46.  
  47. While Not KeyDown(ESC_KEY)
  48.  
  49. x#=0
  50. y#=0
  51. z#=0
  52.  
  53. If KeyDown(LEFT_KEY)=True Then x#=-0.1
  54. If KeyDown(RIGHT_KEY)=True Then x#=0.1
  55. If KeyDown(DOWN_KEY)=True Then y#=-0.1
  56. If KeyDown(UP_KEY)=True Then y#=0.1
  57.  
  58. If CountCollisions (sphere)=True Then HideEntity cone 
  59.  
  60. MoveEntity sphere,x#,y#,z#
  61.  
  62. UpdateWorld
  63. RenderWorld
  64.  
  65. Flip
  66. Wend
  67.  
  68. End