`Terrain Editor program `By Segan Gosub _InitialiseGlobals Gosub _SetupScreen Make Matrix 1, 10, 10, 10, 10 Position Matrix 1, -5, 0, -5 Do MoveCamera(0.13) Sync loop Function MoveCamera(MoveSpeed#) `Notes: `CameraX, CameraY, CameraZ, CamPointX, CamPointY, CamPointZ and CamCirclePos `all have to be globals and have to have values before function is called. tmove = 0 Angle# = Camera Angle Y() tMoveSpeed# = MoveSpeed# If Shiftkey() = 0 If Leftkey() = 1 Then tMove = 1: Angle# = wrapvalue(Angle#+270):Goto MoveCameraNext If Rightkey() = 1 Then tMove = 1: Angle# = wrapvalue(Angle#+90):Goto MoveCameraNext If Upkey() = 1 Then tMove = 1: Angle# = wrapvalue(Angle#): Goto MoveCameraNext If Downkey() = 1 Then tMove = 1: Angle# = wrapvalue(Angle#+180): Goto MoveCameraNext endif MoveCameraNext: If tMove = 1 If Angle# >= 0 AND Angle# <= 180 CameraX = Newxvalue(CameraX, Angle#, tMoveSpeed#) CamPointX = Newxvalue(CamPointX, Angle#, tMoveSpeed#) Endif If Angle# >= 180 And Angle# <= 360 CameraX = Newxvalue(CameraX, Angle#, tMoveSpeed#) CamPointX = Newxvalue(CamPointX, Angle#, tMoveSpeed#) Endif If Angle# >= 270 Or Angle# <= 90 CameraZ = Newzvalue(CameraZ, Angle#, tMoveSpeed#) CamPointZ = Newzvalue(CamPointZ, Angle#, tMoveSpeed#) Endif If Angle# >= 90 And Angle# <= 270 CameraZ = Newzvalue(CameraZ, Angle#, tMoveSpeed#) CamPointZ = Newzvalue(CamPointZ, Angle#, tMoveSpeed#) Endif Endif Position Camera CameraX,CameraY,CameraZ Point Camera CamPointX, CamPointY, CamPointZ tempMouseMove = MouseMoveZ() If tempMouseMove > 0 Then Move Camera MoveSpeed#*3 If tempMouseMove < 0 Then Move Camera -MoveSpeed#*3 CameraX = Camera Position X() CameraY = Camera Position Y() CameraZ = Camera Position Z() If Shiftkey() > 0 If LeftKey() = 1 Then CamCirclePos = Wrapvalue(CamCirclePos - 1.0) If RightKey() = 1 Then CamCirclePos = Wrapvalue(CamCirclePos + 1.0) If Upkey() = 1 Then CameraY = CameraY + MoveSpeed# If Downkey() = 1 Then CameraY = CameraY - MoveSpeed# endif AdjustCamX# = (Sin(CamCirclePos)*abs(CameraZ-CamPointZ))+CameraX AdjustCamZ# = (Cos(CamCirclePos)*abs(CameraZ-CamPointZ))+CameraZ-(CameraZ-CamPointZ) Position Camera AdjustCamX#,CameraY,AdjustCamZ# Point Camera CamPointX, CamPointY, CamPointZ endfunction `======================================================================== _InitialiseGlobals: `--------------------------------------------------------------------- `Camera Variables: `--------------------------------------------------------------------- Global CameraX As Float: CameraX = 0.0 Global CameraY As Float: CameraY = 10.0 Global CameraZ As Float: CameraZ = -5.0 Global CamPointX As Float: CamPointX = 0.0 Global CamPointY As Float: CamPointY = 0.0 Global CamPointZ As Float: CamPointZ = 0.0 Global CamCirclePos As Float: CamCirclePos = 180.0 `!!!Perhaps temporary if a function to find them out can be made.!!! Global PointCameraX As Float: PointCameraX = 0 Global PointCameraY As Float: PointCameraY = 0 Global PointCameraZ As Float: PointCameraZ = 0 Return `======================================================================== _SetupScreen: `Setup the screen Sync On: Sync Rate 60 autocam off backdrop on `Setup the camera Position Camera CameraX,CameraY,CameraZ Point Camera PointCameraX,PointCameraY,PointCameraZ Return