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

  1. rem Tutorial 6
  2.  
  3. rem Initial settings
  4. sync on : sync rate 100
  5. backdrop off : hide mouse
  6.  
  7. rem Select font
  8. set text font "arial" : set text size 16
  9. set text to bold : set text transparent
  10.  
  11. rem Loading prompt
  12. sync : center text screen width()/2,screen height()/2,"LOADING" : sync
  13.  
  14. rem Load all media for game
  15. gosub _load_game
  16.  
  17. rem Setup all objects for game
  18. gosub _setup_game
  19.  
  20. rem Game loop
  21. do
  22.  
  23.  rem Control game elements
  24.  gosub _control_player
  25.  gosub _control_gunandbullet
  26.  gosub _control_enemies
  27.  
  28.  rem Update screen
  29.  sync
  30.  
  31. rem End loop
  32. loop
  33.  
  34. rem End program
  35. end
  36.  
  37. _control_player:
  38.  
  39. rem Control player direction
  40. rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0
  41.  
  42. rem Control player movement
  43. cx#=camera angle x(0) : cy#=camera angle y(0)
  44. if upkey()=1 then xrotate camera 0,0 : move camera 0,0.2 : xrotate camera 0,cx#
  45. if downkey()=1 then xrotate camera 0,0 : move camera 0,-0.2 : xrotate camera 0,cx#
  46. if leftkey()=1 then yrotate camera 0,cy#-90 : move camera 0.2 : yrotate camera 0,cy#
  47. if rightkey()=1 then yrotate camera 0,cy#+90 : move camera 0.2 : yrotate camera 0,cy#
  48. if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180 then xrotate camera 0,40
  49. if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<280 then xrotate camera 0,280
  50.  
  51. rem Apply simple gravity to player
  52. position camera camera position x(),camera position y()-0.1,camera position z()
  53.  
  54. rem Player is always focal point of sky
  55. position object SkyObj,camera position x(),camera position y(),camera position z()
  56.  
  57. rem Position listener at player for 3D sound
  58. position listener camera position x(),camera position y(),camera position z()
  59. rotate listener camera angle x(),camera angle y(),camera angle z()
  60.  
  61. rem In case of restart
  62. if restart=1
  63.    restart=0
  64.    set bsp collision off 1
  65.    rotate camera 0,0,0
  66.    position camera 2,2,2
  67.    set bsp camera collision 1,0,0.75,0
  68. endif
  69.  
  70. return
  71.  
  72. _control_gunandbullet:
  73.  
  74.  rem *ADDCODE* TUT6C
  75.  
  76.  rem *ADDCODE* TUT6D
  77.  
  78. return
  79.  
  80. _control_enemies:
  81. return
  82.  
  83. _control_stats:
  84. return
  85.  
  86. _setup_game:
  87.  
  88.  rem Setup camera
  89.  set camera range 0.1,5000
  90.  autocam off
  91.  
  92.  rem Setup sky model
  93.  set object SkyObj,1,0,0,0,0,0,0
  94.  scale object SkyObj,20,20,20
  95.  
  96.  rem *ADDCODE* TUT6B
  97.  
  98.  rem Trigger player initialisation
  99.  restart=1
  100.  
  101. return
  102.  
  103. _load_game:
  104.  
  105.  rem Load BSP world and sky model
  106.  load bsp "world\ikzdm1.pk3","ikzdm1.bsp"
  107.  SkyObj=1 : load object "models\sky\am.x",SkyObj
  108.  
  109.  rem *ADDCODE* TUT6A
  110.  
  111. return
  112.  
  113.