home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming for Teens (2nd Edition) / 3DGPFT2E.iso / Source / Chapter09 / demo09-04.bb < prev    next >
Encoding:
Text File  |  2009-01-21  |  952 b   |  43 lines

  1. ;demo09-04.bb - Beginning a terrain
  2. ; ------------------
  3. Graphics3D 640,480 
  4. SetBuffer BackBuffer()
  5.  
  6. Const ESC_KEY = 1
  7. Const LEFT_KEY = 203
  8. Const RIGHT_KEY = 205
  9. Const UP_KEY = 200
  10. Const DOWN_KEY = 208
  11.  
  12. ; Create camera
  13. camera=CreateCamera()
  14. PositionEntity camera,0,1,0
  15.  
  16. ; Create a light
  17. light=CreateLight(3)
  18.  
  19. ; Loading the heightmap
  20. terrain=LoadTerrain ( "highmountain.jpg" )
  21. ScaleEntity terrain,5,100,5
  22. PositionEntity terrain,-500,0,-500
  23. tex=LoadTexture( "greenery.jpg" )
  24. ScaleTexture tex, 50,50
  25. EntityTexture terrain,tex
  26.  
  27.  
  28. ; Create the terrain
  29. ground=CreateTerrain(512)
  30.  
  31.  
  32. ; This following code deals with cameras and terrain 
  33. While Not KeyDown(ESC_KEY)
  34.  
  35.     If KeyDown(RIGHT_KEY)=True Then TurnEntity camera,0,-1,0
  36.     If KeyDown(LEFT_KEY)=True Then TurnEntity camera,0,1,0
  37.     If KeyDown(DOWN_KEY)=True Then MoveEntity camera,0,0,-1
  38.     If KeyDown(UP_KEY)=True Then MoveEntity camera,0,0,1
  39.  
  40.     RenderWorld 
  41.     Flip
  42. Wend
  43. End