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

  1. Rem * Title  : Smooth 3rd Person
  2. Rem * Author : DBS-LB
  3. Rem * Date   : 1st Sept 99
  4. rem ==============================================
  5. rem DARK BASIC EXAMPLE PROGRAM 4
  6. rem ==============================================
  7. rem This program operates smooth 3RD 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 cone 1,100.0
  22. xrotate object 1,180
  23.  
  24. rem Set variables for character position
  25. x#=2500
  26. z#=2500
  27.  
  28. rem Activate manual sync
  29. sync on
  30.  
  31. rem Begin loop
  32. do
  33.  
  34. rem Control camera with arrow keys
  35. if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
  36. if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10)
  37. if leftkey()=1 then a#=wrapvalue(a#-10.0)
  38. if rightkey()=1 then a#=wrapvalue(a#+10.0)
  39.  
  40. rem Update character
  41. y#=get ground height(1,x#,z#)+50.0
  42. position object 1,x#,y#,z#
  43. yrotate object 1,a#
  44.  
  45. rem Position camera to the back of the character
  46. ca#=wrapvalue(curveangle(a#,ca#,12.0))
  47. cx#=newxvalue(x#,wrapvalue(ca#+180),300)
  48. cz#=newzvalue(z#,wrapvalue(ca#+180),300)
  49. cy#=get ground height(1,cx#,cz#)+100.0
  50. position camera cx#,cy#,cz#
  51. yrotate camera wrapvalue(ca#)
  52.  
  53. rem Syncronise
  54. sync
  55.  
  56. rem End loop
  57. loop
  58.