home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / fast / caverun / caverun.dba next >
Encoding:
Text File  |  1999-11-21  |  2.9 KB  |  131 lines

  1. Rem * Title  : Cave Runner
  2. Rem * Author : DBS-LB
  3. Rem * Date   : 1st Sept 99
  4. rem ----------------
  5. rem Cave Runner Demo
  6. rem ----------------
  7. rem Author: DBS-LB99
  8. hide mouse
  9.  
  10. rem Load bitmaps
  11. load bitmap "tiles.bmp",1
  12. get image 1,0,0,256,256
  13. delete bitmap 1
  14.  
  15. rem Load sound
  16. load sound "hum.wav",1
  17. load sound "explode.wav",2
  18. loop sound 1
  19.  
  20. rem Load music track
  21. load music "caverun.mid",1
  22. loop music 1
  23.  
  24. rem Activate manual sync
  25. sync on
  26.  
  27. rem Make landscape and ceiling matrix
  28. make matrix 1,2000,5000,10,25
  29. prepare matrix texture 1,1,2,2
  30. make matrix 2,2000,5000,10,25
  31. prepare matrix texture 2,1,2,2
  32. fill matrix 2,0,2
  33. randomize matrix 2,350.0
  34. for t=0 to 25
  35.     set matrix height 2,0,t,-100
  36.     set matrix height 2,10,t,-100
  37. next t
  38. update matrix 2
  39.  
  40. rem Bagin game loop
  41. do
  42.  
  43. rem Set seed for same random numbers
  44. randomize 1
  45.  
  46. rem Clear cave floor
  47. fill matrix 1,0,1
  48.  
  49. rem Set lighting, fog and setupset ambient light 20
  50. color backdrop 0
  51. if fog available()=1 then fog on : fog color 0 : fog distance 3000
  52.  
  53. rem Reset speed
  54. x=0
  55. z=0
  56. speed#=0.0
  57.  
  58. rem Begin main loop
  59. repeat
  60.  
  61. rem Record old variables
  62. oldx=x
  63. oldgy#=gy#
  64.  
  65. rem Control key movements
  66. if upkey()=1 then speed#=speed#+1.0 else speed#=speed#-1.0
  67. if leftkey()=1 then rz#=rz#+1.0
  68. if rightkey()=1 then rz#=rz#-1.0
  69.  
  70. rem Control variables
  71. if speed#<0.0 then speed#=0.0
  72. if speed#<10.0 then speed#=speed#+1.1
  73. if speed#>40.0 then speed#=40.0
  74. rz#=rz#/1.1
  75. x=x-(2*rz#)
  76.  
  77. rem Scroll landscape
  78. z=z+speed#
  79. if z>200
  80.     z=z-200
  81.     if rnd(3)=0
  82.         mp=mp-1
  83.         mp=mp+rnd(3)
  84.         if mp<1 then mp=1
  85.         if mp>4 then mp=4
  86.     endif
  87.     for t=0 to 0 : set matrix height 1,t,24,450 : set matrix tile 1,t,24,2 : next t
  88.     for t=1 to mp : set matrix height 1,t,24,rnd(200) : set matrix tile 1,t,24,2 : next t
  89.     for t=mp+1 to mp+1 : set matrix height 1,t,24,rnd(200) : set matrix tile 1,t,24,3 : next t
  90.     for t=mp+2 to mp+3 : set matrix height 1,t,24,rnd(20) : set matrix tile 1,t,24,1 : next t
  91.     for t=mp+4 to mp+4 : set matrix height 1,t,24,rnd(200) : set matrix tile 1,t,24,4 : next t
  92.     for t=mp+5 to 9 : set matrix height 1,t,24,rnd(200) : set matrix tile 1,t,24,2 : next t
  93.     for t=10 to 10 : set matrix height 1,t,24,450 : next t
  94.     update matrix 1
  95.     shift matrix up 1
  96.     shift matrix up 2
  97. endif
  98.  
  99. rem Position matrix    
  100. position matrix 1,0,0,2500-z
  101. position matrix 2,0,100,2500-z
  102.  
  103. rem Position camera
  104. gy#=curvevalue(50+get ground height(1,500+x,z),gy#,3)
  105. position camera 500+x,gy#,2500
  106. zrotate camera wrapvalue(rz#)
  107.  
  108. rem Control sound frequency
  109. set sound speed 1,10000+(speed#*100)
  110.  
  111. rem Update screen
  112. sync
  113.  
  114. rem End main loop when collision with ceiling
  115. until get ground height(2,500+x,z)<gy#-75.0
  116.  
  117. rem Return camera to point before collision
  118. position camera 500+oldx,oldgy#,2500
  119.  
  120. rem Game Over
  121. play sound 2
  122. for c=0 to 255 step 20
  123.     cls rgb(c,0,0)
  124.     if fog available()=1 then fog distance (c*5) : fog color (c*256*256)
  125.     sync
  126. next c
  127.  
  128. rem End game loop
  129. loop
  130.  
  131.