Fixed a bug I introduced ;)

This commit is contained in:
jme9
2025-03-18 20:45:31 -07:00
parent d50de67f82
commit 0e60bb4207
3 changed files with 12 additions and 20 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ namespace LunaLightXMG
public float Zoom public float Zoom
{ {
get => 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 public float Rotation
{ {
+5 -14
View File
@@ -98,22 +98,12 @@ namespace LunaLightXMG
private void TestCameraWhilePlaying() private void TestCameraWhilePlaying()
{ {
KeyboardState keyboardState = Keyboard.GetState(); KeyboardState keyboardState = Keyboard.GetState();
var KeyI = keyboardState.IsKeyDown(Keys.I);
var KeyO = keyboardState.IsKeyDown(Keys.O);
var KeyK = keyboardState.IsKeyDown(Keys.K); var KeyK = keyboardState.IsKeyDown(Keys.K);
var KeyL = keyboardState.IsKeyDown(Keys.L); var KeyL = keyboardState.IsKeyDown(Keys.L);
var KeyB = keyboardState.IsKeyDown(Keys.B); var KeyB = keyboardState.IsKeyDown(Keys.B);
var KeyN = keyboardState.IsKeyDown(Keys.N); var KeyN = keyboardState.IsKeyDown(Keys.N);
var KeyM = keyboardState.IsKeyDown(Keys.M); var KeyM = keyboardState.IsKeyDown(Keys.M);
if (KeyI)
{
camera2D.Zoom += 1f;
}
if (KeyO)
{
camera2D.Zoom -= 1f;
}
if (KeyK) if (KeyK)
{ {
camera2D.Rotation -= 0.01f; 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, $"Walled: {player.walled}", new Vector2(10, 50), Color.White);
spriteBatch.DrawString(debugFont, $"Position: {player.position}", new Vector2(10, 70), 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 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, 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, 130), Color.White);
spriteBatch.DrawString(debugFont, $"Render Target Zoom: {renderHandler.ZoomLevel}", new Vector2(10, 150), 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, $"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); 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 // reset cam
camera2D.Rotation = 0; camera2D.Rotation = 0;
camera2D.Zoom = 1f; camera2D.Zoom = 1f;
// reset render target zoom
renderHandler.ZoomNormalize();
// Reset player position // Reset player position
player.Reset(new Vector2(163, 0)); player.Reset(new Vector2(163, 0));
+6 -5
View File
@@ -12,8 +12,8 @@ namespace LunaLightXMG
private RenderTarget2D renderTarget; private RenderTarget2D renderTarget;
private Rectangle renderDestination; private Rectangle renderDestination;
private float retroWidth; private readonly float retroWidth;
private float retroHeight; private readonly float retroHeight;
private float zoomLevel = 1.0f; private float zoomLevel = 1.0f;
private float zoomTarget = 1.0f; private float zoomTarget = 1.0f;
private readonly float zoomMin = 0.50f; private readonly float zoomMin = 0.50f;
@@ -71,10 +71,11 @@ namespace LunaLightXMG
// Calculate the integer scale factor // Calculate the integer scale factor
float scaleX = screenSize.X / (retroWidth * zoomLevel); float scaleX = screenSize.X / (retroWidth * zoomLevel);
float scaleY = screenSize.Y / (retroHeight * zoomLevel); float scaleY = screenSize.Y / (retroHeight * zoomLevel);
float scale = Math.Min(scaleX, scaleY);
// Set renderDestination // Set renderDestination
renderDestination.Width = (int)(retroWidth * scaleX); renderDestination.Width = (int)(retroWidth * scale);
renderDestination.Height = (int)(retroHeight * scaleY); renderDestination.Height = (int)(retroHeight * scale);
renderDestination.X = (screenSize.X - renderDestination.Width) / 2; renderDestination.X = (screenSize.X - renderDestination.Width) / 2;
renderDestination.Y = (screenSize.Y - renderDestination.Height) / 2; renderDestination.Y = (screenSize.Y - renderDestination.Height) / 2;
} }