home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming for Teens (2nd Edition) / 3DGPFT2E.iso / Source / Chapter12 / demo12-01.bb < prev    next >
Text File  |  2009-01-20  |  2KB  |  89 lines

  1. ;demo12-01.bb - Playing Sounds
  2. ; ------------------
  3. Graphics3D 640,480 
  4. SetBuffer BackBuffer()
  5.  
  6. Const ESC_KEY = 1
  7. Const LEFT_KEY = 203
  8. Const RIGHT_KEY = 205
  9. Const UP_KEY = 200
  10. Const DOWN_KEY = 208
  11. Const A_KEY = 30
  12. Const Z_KEY = 44
  13.  
  14. ; Creating the types
  15. type_player=1
  16. type_ground=2
  17. type_enemy=3
  18.  
  19. ;Load the sound
  20. blaster = LoadSound ("blaster.wav")
  21. ; Creating a light
  22.  
  23. light=CreateLight()
  24.  
  25. ; Create camera
  26. camera=CreateCamera()
  27. PositionEntity camera, 0,1,0
  28.  
  29. ; Creating a terrain
  30.  
  31. ground=CreatePlane()
  32. EntityColor ground, 34,53,123
  33. EntityType ground,type_ground
  34.  
  35. ; Create Sphere
  36.  
  37. sphere=CreateSphere(64)
  38. PositionEntity sphere, 0,1,3
  39. EntityType sphere,type_player
  40. ScaleEntity sphere ,0.2,0.2,0.2
  41. EntityRadius sphere, 0.1
  42.  
  43.  
  44. Texture=CreateTexture(16,16): SetBuffer TextureBuffer(texture)
  45. ClsColor 12,35,36
  46. Cls
  47. Color 123,256,256
  48. Rect 0,0,8,8,1
  49. Rect 8,8,8,8,1
  50. ScaleTexture Texture,.2,.2
  51. EntityTexture sphere,texture
  52.  
  53. ; Create Cube
  54.  
  55. cube=CreateCube()
  56. PositionEntity cube, -2,1,3
  57. ScaleEntity cube, 0.2,0.2,0.2
  58. EntityType cube, type_enemy
  59.  
  60. ; This following code makes our program run
  61.  
  62. Collisions type_player,type_ground,2,2
  63. Collisions type_ground,type_player,2,2
  64. Collisions type_player,type_enemy,2,2
  65.  
  66. While Not KeyDown(ESC_KEY)
  67.     x#=0
  68.     y#=0
  69.     z#=0
  70.  
  71.     If KeyDown(LEFT_KEY)=True Then x#=-0.05
  72.     If KeyDown(RIGHT_KEY)=True Then x#=0.05
  73.     If KeyDown(DOWN_KEY)=True Then y#=-0.05
  74.     If KeyDown(UP_KEY)=True Then y#=0.05
  75.     If KeyDown(Z_KEY)=True Then z#=-0.05
  76.     If KeyDown(A_KEY)=True Then z#=0.05
  77.     MoveEntity sphere,x#,y#,z#
  78.     ; Collision Sound
  79.     If CountCollisions (sphere)
  80.         PlaySound blaster
  81.     EndIf
  82.     
  83.     
  84.  
  85.     UpdateWorld
  86.     RenderWorld 
  87.     Flip
  88. Wend
  89. End