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

  1. ;demo09-06.bb - Shapes and 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()
  18.  
  19. ;Create our terrain
  20. ground=CreateTerrain(512)
  21. PositionEntity ground, -500,0,-500
  22. ScaleEntity ground, 10,15,10
  23. tex=LoadTexture( "greenery.jpg" )
  24. EntityTexture ground, tex
  25.  
  26.  
  27. ;Creating the sky
  28. sky = CreateSphere (40)
  29. FlipMesh sky
  30. ScaleEntity sky, 100,100,100
  31. PositionEntity sky, 0,50,0
  32. sky_tex = LoadTexture ( "sky2.jpg" )
  33. EntityTexture sky,sky_tex
  34. EntityFX sky,1
  35.  
  36.  
  37. ; Create the terrain
  38. ground=CreateTerrain(512)
  39.  
  40.  
  41. ; This following code deals with cameras and terrain 
  42. While Not KeyDown(ESC_KEY)
  43.  
  44.     If KeyDown(RIGHT_KEY)=True Then TurnEntity camera,0,-1,0
  45.     If KeyDown(LEFT_KEY)=True Then TurnEntity camera,0,1,0
  46.     If KeyDown(DOWN_KEY)=True Then MoveEntity camera,0,0,-0.5
  47.     If KeyDown(UP_KEY)=True Then MoveEntity camera,0,0,0.5
  48.  
  49.     RenderWorld 
  50.     Flip
  51. Wend
  52. End