home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / sound / exam08.dba < prev    next >
Encoding:
Text File  |  1999-12-10  |  1.9 KB  |  76 lines

  1. Rem * Title  : Demonstrate 3D Sound
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ==============================================
  5. rem DARK BASIC EXAMPLE PROGRAM 8
  6. rem ==============================================
  7. rem This program demonstrates a simple 3D sound
  8. rem ----------------------------------------------
  9.  
  10. rem SOUND COMMAND : Load a 3d sound
  11. load 3dsound "sound.wav",1
  12. loop sound 1
  13. pause sound 1
  14.  
  15. rem Make a simple scene for the camera to look at
  16. make matrix 1,10000.0,10000.0,25,25
  17. load bitmap "rock1.bmp",1
  18. get image 1,0,0,256,256
  19. delete bitmap 1
  20. prepare matrix texture 1,1,1,1
  21. randomize matrix 1,20.0
  22.  
  23. rem Create characters to see
  24. make object sphere 1,100.0
  25. make object cylinder 2,100.0
  26.  
  27. rem Set variables for character position
  28. x#=5000
  29. z#=5000
  30.  
  31. rem Resume sound
  32. resume sound 1
  33.  
  34. rem Activate manual sync
  35. sync on
  36.  
  37. rem Begin loop
  38. do
  39.  
  40. rem Control camera with arrow keys
  41. if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
  42. if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10)
  43. if leftkey()=1 then a#=wrapvalue(a#-10.0)
  44. if rightkey()=1 then a#=wrapvalue(a#+10.0)
  45.  
  46. rem Update character
  47. y#=get ground height(1,x#,z#)+50.0
  48. position object 1,x#,y#,z#
  49. yrotate object 1,a#
  50.  
  51. rem Position camera to the back of the character
  52. ca#=wrapvalue(curveangle(a#,ca#,12.0))
  53. cx#=newxvalue(x#,wrapvalue(ca#+180),300)
  54. cz#=newzvalue(z#,wrapvalue(ca#+180),300)
  55. cy#=get ground height(1,cx#,cz#)+100.0
  56. position camera cx#,cy#,cz#
  57. yrotate camera wrapvalue(ca#)
  58.  
  59. rem Make object 2 look like a generator
  60. rr#=wrapvalue(rr#+3.0)
  61. position object 2,4000,25+(cos(rr#)*20),4000
  62.  
  63. rem SOUND COMMANDS
  64. rem Position sound at object 2
  65. position sound 1,object position x(2),0,object position z(2)
  66.  
  67. rem Position our listener at camera
  68. position listener cx#,cy#,cz#
  69. rotate listener 0,wrapvalue(360.0-ca#),0
  70.  
  71. rem Syncronise
  72. sync
  73.  
  74. rem End loop
  75. loop
  76.