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

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