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

  1. ;demo13-03.bb - Velocity
  2. ;_______________
  3.  
  4.  
  5. camdistance=10
  6.  
  7. Graphics3D 640,480
  8. SetBuffer BackBuffer()
  9.  
  10.  
  11. ;Key Constants
  12. Const ESC_KEY = 1
  13. Const UP_KEY = 200
  14. Const DOWN_KEY = 208
  15. Const S_KEY = 31
  16.  
  17.  
  18. ; Creating the types
  19.  
  20. type_player=1
  21. type_ground=2
  22.  
  23.  
  24. ; Create camera
  25. camera=CreateCamera(pivot)
  26. PositionEntity camera, 15,7,0
  27. RotateEntity camera, 30,0,0
  28.  
  29.  
  30. ; Creating a light
  31.  
  32. light=CreateLight()
  33.  
  34. ; Creating a terrain
  35.  
  36. terrain=CreateTerrain(512)
  37. EntityColor terrain, 125,136,32
  38. PositionEntity terrain, -300,-1,-100
  39. EntityType terrain,type_ground
  40.  
  41. ; Creating the sky
  42.  
  43. sky=CreateSphere(32)
  44. ScaleEntity sky, 100,100,100
  45. EntityColor sky, 102,153,255
  46. FlipMesh sky
  47.  
  48.  
  49. ; Creating a sphere
  50.  
  51. sphere=CreateSphere(64)
  52. PositionEntity sphere, 15,3,9
  53. EntityType sphere,type_player
  54. ScaleEntity sphere ,0.4,0.4,0.2
  55. EntityRadius sphere, 0.5
  56. Texture=CreateTexture(16,16): SetBuffer TextureBuffer(texture)
  57. ClsColor 12,35,36
  58. Cls
  59. Color 123,256,256
  60. Rect 0,0,8,8,1
  61. Rect 8,8,8,8,1
  62. ScaleTexture Texture,.2,.2
  63. EntityTexture sphere,texture
  64.  
  65. ;Creating a pivot
  66.  
  67. pivot=CreatePivot(sphere)
  68. MoveEntity pivot, 0,0,-camdistance
  69.  
  70.  
  71. ; This following code makes our program run
  72.  
  73. While Not KeyDown(ESC_KEY)
  74.     TranslateEntity sphere, 0,-0.03,0
  75.     Collisions type_player,type_ground,2,2
  76.     Collisions type_ground,type_player,2,2
  77.     
  78.     
  79.     UpdateWorld
  80.     RenderWorld
  81.     Flip
  82. Wend
  83.  
  84. End