CameraClsMode.bb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ; CameraClsMode Example
  2. ; ---------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. PositionEntity camera,0,1,-10
  7. light=CreateLight()
  8. RotateEntity light,90,0,0
  9. plane=CreatePlane()
  10. ground_tex=LoadTexture("media/MossyGround.bmp")
  11. EntityTexture plane,ground_tex
  12. cube=CreateCube()
  13. PositionEntity cube,0,1,0
  14. ; Load 2D background image
  15. background=LoadImage("media/sky.bmp")
  16. ; Use red ink color so we can see text on top of black or light blue background
  17. Color 255,0,0
  18. While Not KeyDown(1)
  19. If KeyDown(205)=True Then TurnEntity camera,0,-1,0
  20. If KeyDown(203)=True Then TurnEntity camera,0,1,0
  21. If KeyDown(208)=True Then MoveEntity camera,0,0,-0.05
  22. If KeyDown(200)=True Then MoveEntity camera,0,0,0.05
  23. ; Toggle cls_color value between 0 and 1 when spacebar is pressed
  24. If KeyHit(57)=True Then cls_color=1-cls_color
  25. ; Set the camera clear mode, using the cls_color value
  26. CameraClsMode camera,cls_color,1
  27. ; Draw a 2D background. When cls_color is set to 0, the 2D graphics will show behind the 3D graphics.
  28. TileBlock background,0,0
  29. RenderWorld
  30. Text 0,0,"Use cursor keys to move about"
  31. Text 0,20,"Press space bar to enable/disable colour clearing"
  32. Text 0,40,"CameraClsMode camera,"+cls_color+","+1
  33. Flip
  34. Wend
  35. End