CameraZoom.bb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ; CreateZoom Example
  2. ; ------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. PositionEntity camera,0,1,0
  7. light=CreateLight()
  8. RotateEntity light,90,0,0
  9. ground=CreatePlane()
  10. sand_tex=LoadTexture("media/sand.bmp")
  11. ScaleTexture sand_tex,10,10
  12. EntityTexture ground,sand_tex
  13. EntityColor ground,168,133,55
  14. cactus1=LoadMesh("media/CACTUS2.x")
  15. cactus2=LoadMesh("media/CACTUS2.x")
  16. camel=LoadMesh("media/camel.x")
  17. PositionEntity cactus1,-1,2,10
  18. PositionEntity cactus2,1,2,10
  19. PositionEntity camel,0,1,1000
  20. ; Set initial zoom value
  21. zoom#=1
  22. While Not KeyDown( 1 )
  23. If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
  24. If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
  25. ; Change zoom value depending on key pressed
  26. If KeyDown( 208 )=True Then zoom#=zoom#-0.1
  27. If KeyDown( 200 )=True Then zoom#=zoom#+0.1
  28. ; Put a minimum and maximum cap on zoom value
  29. If zoom#<1 Then zoom#=1
  30. If zoom#>100 Then zoom#=100
  31. ; Set camera zoom
  32. CameraZoom camera,zoom#
  33. RenderWorld
  34. Text 0,0,"Use left and right cursor keys to turn around"
  35. Text 0,20,"Use up and down cursor keys to change camera zoom"
  36. Text 0,40,"There is a camel on the horizon, inbetween the cacti. Zoom in to see it."
  37. Text 0,60,"CameraZoom camera,"+zoom#
  38. Flip
  39. Wend
  40. End