diff --git a/Camera2D.cs b/Camera2D.cs index 0fd4852..d476759 100644 --- a/Camera2D.cs +++ b/Camera2D.cs @@ -22,7 +22,7 @@ namespace LunaLightXMG public float Zoom { get => zoom; - set => zoom = (int)Math.Floor(MathHelper.Clamp(value, 1f, 3f)); + set => zoom = (int)Math.Floor(MathHelper.Clamp(value, 1f, 2f)); } public float Rotation { diff --git a/LunaLightGame.cs b/LunaLightGame.cs index 0751c79..c6603b9 100644 --- a/LunaLightGame.cs +++ b/LunaLightGame.cs @@ -98,22 +98,12 @@ namespace LunaLightXMG private void TestCameraWhilePlaying() { KeyboardState keyboardState = Keyboard.GetState(); - var KeyI = keyboardState.IsKeyDown(Keys.I); - var KeyO = keyboardState.IsKeyDown(Keys.O); var KeyK = keyboardState.IsKeyDown(Keys.K); var KeyL = keyboardState.IsKeyDown(Keys.L); var KeyB = keyboardState.IsKeyDown(Keys.B); var KeyN = keyboardState.IsKeyDown(Keys.N); var KeyM = keyboardState.IsKeyDown(Keys.M); - if (KeyI) - { - camera2D.Zoom += 1f; - } - if (KeyO) - { - camera2D.Zoom -= 1f; - } if (KeyK) { camera2D.Rotation -= 0.01f; @@ -263,12 +253,10 @@ namespace LunaLightXMG spriteBatch.DrawString(debugFont, $"Walled: {player.walled}", new Vector2(10, 50), Color.White); spriteBatch.DrawString(debugFont, $"Position: {player.position}", new Vector2(10, 70), Color.White); spriteBatch.DrawString(debugFont, $"Camera Position: {camera2D.Position}", new Vector2(10, 90), Color.White); - spriteBatch.DrawString(debugFont, $"Camera Zoom: {camera2D.Zoom}", new Vector2(10, 110), Color.White); - spriteBatch.DrawString(debugFont, $"Camera Rotation: {camera2D.Rotation}", new Vector2(10, 130), Color.White); - spriteBatch.DrawString(debugFont, $"Render Target Zoom: {renderHandler.ZoomLevel}", new Vector2(10, 150), Color.White); + spriteBatch.DrawString(debugFont, $"Camera Rotation: {camera2D.Rotation}", new Vector2(10, 110), Color.White); + spriteBatch.DrawString(debugFont, $"Render Target Zoom: {renderHandler.ZoomLevel}", new Vector2(10, 130), Color.White); - spriteBatch.DrawString(debugFont, $"Camera Zoom Control - Zoom in: I, Zoom out: O", new Vector2(10, 170), Color.White); spriteBatch.DrawString(debugFont, $"Camera Rotation Control - Rotate left: K, Rotate right: L", new Vector2(10, 190), Color.White); spriteBatch.DrawString(debugFont, $"Render Target Zoom Control - Zoom in: B, Zoom normal: N, Zoom out: M", new Vector2(10, 210), Color.White); @@ -285,6 +273,9 @@ namespace LunaLightXMG // reset cam camera2D.Rotation = 0; camera2D.Zoom = 1f; + + // reset render target zoom + renderHandler.ZoomNormalize(); // Reset player position player.Reset(new Vector2(163, 0)); diff --git a/RenderHandler.cs b/RenderHandler.cs index 7506bf7..7866c83 100644 --- a/RenderHandler.cs +++ b/RenderHandler.cs @@ -12,8 +12,8 @@ namespace LunaLightXMG private RenderTarget2D renderTarget; private Rectangle renderDestination; - private float retroWidth; - private float retroHeight; + private readonly float retroWidth; + private readonly float retroHeight; private float zoomLevel = 1.0f; private float zoomTarget = 1.0f; private readonly float zoomMin = 0.50f; @@ -71,10 +71,11 @@ namespace LunaLightXMG // Calculate the integer scale factor float scaleX = screenSize.X / (retroWidth * zoomLevel); float scaleY = screenSize.Y / (retroHeight * zoomLevel); - + float scale = Math.Min(scaleX, scaleY); + // Set renderDestination - renderDestination.Width = (int)(retroWidth * scaleX); - renderDestination.Height = (int)(retroHeight * scaleY); + renderDestination.Width = (int)(retroWidth * scale); + renderDestination.Height = (int)(retroHeight * scale); renderDestination.X = (screenSize.X - renderDestination.Width) / 2; renderDestination.Y = (screenSize.Y - renderDestination.Height) / 2; }