home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Help / examples / music / music1-example.dba < prev    next >
Encoding:
Text File  |  2004-09-22  |  2.5 KB  |  101 lines

  1. rem Music Showcase
  2.  
  3. rem Standard Setup Code for all examples
  4. sync on : sync rate 0 : backdrop off
  5. set text font "arial" : set text size 16
  6. set text to bold : set text transparent
  7.  
  8. rem Loading prompt
  9. sync : center text screen width()/2,screen height()/2,"LOADING" : sync
  10.  
  11. rem Load room
  12. load object "world\room.x",1
  13. xrotate object 1,270
  14. fix object pivot 1
  15. rotate object 1,0,0,0
  16. set object specular 1,0
  17.  
  18. rem Load for selection
  19. for t=2 to 5
  20.  if t=2 then load object "models\harp\harp.x",t : tx=-100 : ta=135
  21.  if t=3 then load object "models\trumpet\trumpet.x",t : tx=-200 : ta=90
  22.  if t=4 then load object "models\piano\piano2.x",t : tx=100 : ta=315
  23.  if t=5 then load object "models\mandolin\mandolin.x",t : tx=-150 : ta=90
  24.  position object t,tx,0,40-(((t-3)*80))
  25.  rotate object t,270,ta,0
  26.  scale object t,25,25,25
  27.  fix object pivot t
  28.  rotate object t,0,180,0
  29.  set object specular t,0
  30. next t
  31.  
  32. rem Load music
  33. load music "music\space.mp3",1 : loop music 1
  34. load music "music\misty.mp3",2
  35. load music "music\fun.mp3",3
  36. load music "music\hero.mp3",4
  37.  
  38. rem Setup camera and light
  39. set point light 0,0,0,0
  40. position camera -450,100,10
  41. yrotate camera 90
  42.  
  43. rem Select first globe (via Xangle trigger)
  44. xrotate object 2,1
  45.  
  46. rem Main loop
  47. desc$="Music Room (Select An Instrument)"
  48. do
  49.  
  50. rem Control mouse selector
  51. if mouseclick()=1
  52.  sel=0
  53.  if mousex()>70 and mousex()<600
  54.    sel=1+((mousex()-70)/(530/4))
  55.    if sel>4 then sel=4
  56.  endif
  57.  if sel>0
  58.   for t=2 to 5
  59.    if t<>(1+sel) and object angle x(t)=1
  60.     xrotate object t,0
  61.    if t=2 then stop music 1
  62.    if t=3 then stop music 2
  63.    if t=4 then stop music 3
  64.    if t=5 then stop music 4
  65.    endif
  66.   next t
  67.   if object angle x(1+sel)=0
  68.    xrotate object 1+sel,1
  69.    if sel=1 then loop music 1
  70.    if sel=2 then loop music 2
  71.    if sel=3 then loop music 3
  72.    if sel=4 then loop music 4
  73.   endif
  74.  endif
  75. endif
  76.  
  77. rem Control selected sphere
  78. for t=2 to 5
  79.  a#=wrapvalue(object angle y(t)+1)
  80.  if object angle x(t)=0 and a#=1.0 then a#=0
  81.  yrotate object t,a#
  82.  a#=object angle y(t)
  83.  position object t,object position x(t),50-(cos(a#)*50),40-(((t-3)*80))
  84.  if object angle x(t)=1 then lightz#=object position z(t) : lighty#=object position y(t)
  85. next t
  86.  
  87. rem Control light
  88. position light 0,-250,lighty#+50,lightz#
  89.  
  90. rem Show Framerate
  91. text 20,screen height()-40,desc$
  92. fps$="DBPro Fps: "+str$(screen fps())
  93. text screen width()-20-text width(fps$),screen height()-40,fps$
  94.  
  95. rem Update screen
  96. sync
  97.  
  98. rem End loop
  99. loop
  100.  
  101.