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

  1. ; demo12-03.bb - Panning sound
  2. ; _______________
  3.  
  4. Graphics3D 640,480
  5. SetBuffer BackBuffer()
  6.  
  7. Const ESC_KEY = 1
  8. Const LEFT_KEY = 203
  9. Const RIGHT_KEY = 205
  10.  
  11. ; Creating a light
  12.  
  13. light=CreateLight()
  14.  
  15. ; Create camera
  16. camera=CreateCamera()
  17. PositionEntity camera, 0,1,0
  18.  
  19. ; Creating a terrain
  20.  
  21. ground=CreatePlane()
  22. EntityColor ground, 34,53,123
  23. EntityType ground,type_ground
  24.  
  25. ; Create Sphere
  26.  
  27. sphere=CreateSphere(64)
  28. PositionEntity sphere, 0,1,3
  29. EntityType sphere,type_player
  30. ScaleEntity sphere ,0.2,0.2,0.2
  31. EntityRadius sphere, 0.1
  32.  
  33.  
  34. Texture=CreateTexture(16,16): SetBuffer TextureBuffer(texture)
  35. ClsColor 12,35,36
  36. Cls
  37. Color 123,256,256
  38. Rect 0,0,8,8,1
  39. Rect 8,8,8,8,1
  40. ScaleTexture Texture,.2,.2
  41. EntityTexture sphere,texture
  42.  
  43. ; Loading sound
  44. train = LoadSound ("train.wav")
  45.  
  46.  
  47. ; Running the program
  48.  
  49. While Not KeyDown(ESC_KEY)
  50.  
  51. x#=0
  52.  
  53. If KeyDown(LEFT_KEY)=True Then x#=-0.1
  54. If KeyDown(RIGHT_KEY)=True Then x#=0.1
  55. If x# > 0
  56. pan# = 1
  57. Else
  58. pan# = -1
  59. EndIf
  60.  
  61. If x# <> 0
  62. SoundPan train, pan#
  63. PlaySound train
  64. EndIf
  65. UpdateWorld
  66.  
  67. MoveEntity sphere, x#,0,0
  68.  
  69. RenderWorld
  70.  
  71. Flip
  72. Wend
  73.  
  74. End