diff --git a/Game/Behaviours/CameraController.cs b/Game/Behaviours/CameraController.cs index 641a51d..242f310 100644 --- a/Game/Behaviours/CameraController.cs +++ b/Game/Behaviours/CameraController.cs @@ -9,6 +9,8 @@ public class CameraController : BehaviourOverride private MonoGameCameraBehaviour cameraBehaviour = null!; private IButtonInputs buttonInputs = null!; + private float defaultZoomLevel = 1f; + protected override void OnFirstActiveFrame() { if (BehaviourController.TryGetBehaviour(out MonoGameCameraBehaviour? foundCameraBehaviour)) @@ -21,6 +23,7 @@ public class CameraController : BehaviourOverride buttonInputs ??= BehaviourController.AddBehaviour(); buttonInputs.RegisterOnPress(Keys.F, SwitchToFullScreen); + buttonInputs.RegisterOnPress(Keys.R, ResetCamera); } protected override void OnUpdate() @@ -49,7 +52,15 @@ public class CameraController : BehaviourOverride float previousScreenSize = Math.Sqrt(Math.Pow(cameraBehaviour.Viewport.Width, 2f) + Math.Pow(cameraBehaviour.Viewport.Height, 2f)); float currentScreenSize = Math.Sqrt(Math.Pow(Game1.graphics.GraphicsDevice.Viewport.Width, 2f) + Math.Pow(Game1.graphics.GraphicsDevice.Viewport.Height, 2f)); + defaultZoomLevel /= previousScreenSize / currentScreenSize; cameraBehaviour.Zoom /= previousScreenSize / currentScreenSize; cameraBehaviour.Viewport = Game1.graphics.GraphicsDevice.Viewport; } + + private void ResetCamera(IButtonInputs inputs, Keys keys) + { + cameraBehaviour.Zoom = defaultZoomLevel; + Transform.Position = Vector2D.Zero; + Transform.Rotation = 0f; + } }