home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming for Teens (2nd Edition) / 3DGPFT2E.iso / Source / Chapter13 / demo13-09.bb < prev    next >
Encoding:
Text File  |  2009-01-21  |  1.1 KB  |  65 lines

  1. ;demo13-09.bb - bullet
  2. ;______
  3.  
  4. Graphics3D 640,480
  5. SetBuffer BackBuffer()
  6.  
  7.  
  8. Const ESC_KEY = 1
  9. Const UP_KEY = 200
  10. Const DOWN_KEY = 208
  11. Const LEFT_KEY = 203
  12. Const RIGHT_KEY = 205
  13. Const SPACE_BAR = 57
  14. Const R_KEY = 19
  15. ; Create camera
  16. camera=CreateCamera()
  17.  
  18. ;Create light
  19. light=CreateLight()
  20.  
  21. ; Creating the background
  22.  
  23. background=CreateSphere(32)
  24. ScaleEntity background, 200,200,200
  25. FlipMesh background
  26. EntityColor background, 255,214,100
  27.  
  28. ;Creating the gun
  29.  
  30. gun=CreateCylinder(12)
  31. ScaleEntity gun,0.2,0.6,0.4
  32. RotateEntity gun,45,0,0
  33. PositionEntity gun, EntityX(camera),EntityY(camera)-2, EntityZ(camera)+3
  34. EntityOrder gun, -1
  35. EntityParent gun,camera
  36. EntityColor gun, 100,100,100
  37. maxbull=100
  38.  
  39.  
  40. While Not KeyDown(ESC_KEY)
  41.  
  42. ;Camera Controls
  43.  
  44. If KeyDown(UP_KEY)= True Then cz#=cz#+.01
  45. If KeyDown (DOWN_KEY)= True Then cz#=cz#-.01
  46. If KeyDown(RIGHT_KEY)= True Then rx#=rx#-1
  47. If KeyDown (LEFT_KEY)= True Then rx#=rx#+1
  48.  
  49.  
  50. ;Control camera turning radius
  51.  
  52. If rx# > 180 Then rx#=-180
  53. If rx# < -180 Then rx# = 180
  54.  
  55.  
  56. MoveEntity camera, 0,cy#,cz#
  57. RotateEntity camera, 0,rx#,0
  58.  
  59.  
  60. RenderWorld
  61.  
  62. Flip
  63.  
  64. Wend
  65. End