example.bb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ; Include matrix source code file. We can then use the functions contained within it.
  2. Include "matrix.bb"
  3. Graphics3D 640,480,16
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. CameraClsColor camera,0,0,127
  7. PositionEntity camera,500,500,0
  8. RotateEntity camera,45,0,0
  9. light=CreateLight()
  10. RotateEntity light,90,0,0
  11. ; Clear texture filters - this means textures won't be mipmapped for that rough DB look
  12. ClearTextureFilters
  13. ; Load image to be used as matrix texture
  14. DB_LoadImage("tiles.bmp",1)
  15. ; Make matrix
  16. MakeMatrix(1,1000,1000,10,10)
  17. ; Prepare matrix texture
  18. PrepareMatrixTexture(1,1,2,2)
  19. ; Fill matrix with texture
  20. FillMatrix(1,0,1)
  21. ; Randomize matrix to make it hilly
  22. RandomizeMatrix(1,100)
  23. While KeyDown(1)<>True
  24. mxs=MouseXSpeed()
  25. mys=MouseYSpeed()
  26. dest_xang#=dest_xang#+mys
  27. dest_yang#=dest_yang#-mxs
  28. xang#=CurveValue#(xang#,dest_xang#,5)
  29. yang#=CurveValue#(yang#,dest_yang#,5)
  30. RotateEntity camera,xang#,yang#,0
  31. MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
  32. If MouseDown(1)=True Then MoveEntity camera,0,0,1
  33. ; Position camera at ground height+50
  34. PositionEntity camera,EntityX#(camera),GetGroundHeight#(1,EntityX#(camera),EntityZ#(camera))+50,EntityZ#(camera)
  35. RenderWorld
  36. Flip
  37. Wend
  38. ;---------------------
  39. ; Curve value function
  40. ;---------------------
  41. Function CurveValue#(current#,destination#,curve)
  42. current#=current#+((destination#-current#)/curve)
  43. Return current#
  44. End Function