home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / camera3d / exam03.dba < prev    next >
Encoding:
Text File  |  1999-09-07  |  1.4 KB  |  58 lines

  1. Rem * Title  : Third Person Camera
  2. Rem * Author : DBS-LB
  3. Rem * Date   : 1st Sept 99
  4. rem ===========================================
  5. rem DARK BASIC EXAMPLE PROGRAM 3
  6. rem ===========================================
  7. rem This program operates a third person camera
  8. rem -------------------------------------------
  9.  
  10. rem Make a simple scene for the camera to look at
  11. make matrix 1,10000.0,10000.0,25,25
  12. load bitmap "floor1.bmp",1
  13. get image 1,0,0,256,256
  14. delete bitmap 1
  15. prepare matrix texture 1,1,2,2
  16. randomize matrix 1,50.0
  17. set matrix height 1,12,12,300.0
  18. update matrix 1
  19.  
  20. rem Create blob character to follow
  21. make object sphere 1,100.0
  22.  
  23. rem Set variables for character position
  24. x#=500
  25. z#=500
  26.  
  27. rem Activate manual sync
  28. sync on
  29.  
  30. rem Begin loop
  31. do
  32.  
  33. rem Control camera with arrow keys
  34. if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
  35. if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10)
  36. if leftkey()=1 then a#=wrapvalue(a#-10.0)
  37. if rightkey()=1 then a#=wrapvalue(a#+10.0)
  38.  
  39. rem Update character
  40. y#=get ground height(1,x#,z#)+50.0
  41. position object 1,x#,y#,z#
  42. yrotate object 1,a#
  43.  
  44. rem Position camera to the back of the character
  45. cx#=newxvalue(x#,wrapvalue(a#+180),300)
  46. cz#=newzvalue(z#,wrapvalue(a#+180),300)
  47. cy#=get ground height(1,cx#,cz#)+100.0
  48. position camera cx#,cy#,cz#
  49.  
  50. rem Point camera at object
  51. point camera x#,y#,z#
  52.  
  53. rem Syncronise
  54. sync
  55.  
  56. rem End loop
  57. loop
  58.