mirror of
https://github.com/TheRavenwoodArts/LunaLightXMG.git
synced 2026-07-30 22:55:03 -07:00
Bug Fix: Set player positions to snap to integer values to fix pixel distortion.
This commit is contained in:
@@ -61,7 +61,7 @@ namespace LunaLightXMG
|
|||||||
graphics.PreferredBackBufferHeight = 1080;
|
graphics.PreferredBackBufferHeight = 1080;
|
||||||
graphics.ApplyChanges();
|
graphics.ApplyChanges();
|
||||||
|
|
||||||
playerInput.HasControl = true; // Do we need this here?
|
playerInput.HasControl = true; // May need to find a new home for this
|
||||||
|
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
CalculateRenderDestination();
|
CalculateRenderDestination();
|
||||||
@@ -71,10 +71,15 @@ namespace LunaLightXMG
|
|||||||
{
|
{
|
||||||
Point size = GraphicsDevice.Viewport.Bounds.Size;
|
Point size = GraphicsDevice.Viewport.Bounds.Size;
|
||||||
|
|
||||||
float scaleX = (float)size.X / renderTarget.Width;
|
// Calculate the integer scale factor
|
||||||
float scaleY = (float)size.Y / renderTarget.Height;
|
int scaleX = size.X / renderTarget.Width;
|
||||||
float scale = Math.Min(scaleX, scaleY);
|
int scaleY = size.Y / renderTarget.Height;
|
||||||
|
int scale = Math.Min(scaleX, scaleY);
|
||||||
|
|
||||||
|
// Ensure the scale is at least 1
|
||||||
|
scale = Math.Max(scale, 1);
|
||||||
|
|
||||||
|
// Set renderDestination
|
||||||
renderDestination.Width = (int)(renderTarget.Width * scale);
|
renderDestination.Width = (int)(renderTarget.Width * scale);
|
||||||
renderDestination.Height = (int)(renderTarget.Height * scale);
|
renderDestination.Height = (int)(renderTarget.Height * scale);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace LunaLightXMG
|
|||||||
private float vspJump; // Jump speed
|
private float vspJump; // Jump speed
|
||||||
|
|
||||||
// Player position
|
// Player position
|
||||||
public Vector2 Position;
|
public Vector2 position;
|
||||||
|
|
||||||
// Constructor to initialize variables
|
// Constructor to initialize variables
|
||||||
public Player()
|
public Player()
|
||||||
@@ -45,7 +45,7 @@ namespace LunaLightXMG
|
|||||||
vspMaxWall = 5f;
|
vspMaxWall = 5f;
|
||||||
vspJump = -10f;
|
vspJump = -10f;
|
||||||
|
|
||||||
Position = new Vector2(163, 63); // Initialize player position
|
position = new Vector2(163, 63); // Initialize player position
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method to handle movement logic
|
// Update method to handle movement logic
|
||||||
@@ -54,8 +54,8 @@ namespace LunaLightXMG
|
|||||||
Movement(input);
|
Movement(input);
|
||||||
|
|
||||||
// Update player position based on speed
|
// Update player position based on speed
|
||||||
Position.X += hsp;
|
position.X += hsp;
|
||||||
Position.Y += vsp;
|
position.Y += vsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Movement(PlayerInput input)
|
private void Movement(PlayerInput input)
|
||||||
@@ -111,7 +111,9 @@ namespace LunaLightXMG
|
|||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch, Texture2D texture)
|
public void Draw(SpriteBatch spriteBatch, Texture2D texture)
|
||||||
{
|
{
|
||||||
spriteBatch.Draw(texture, Position, Color.White);
|
// Snap position to integer values
|
||||||
|
Vector2 drawPosition = new Vector2((int)position.X, (int)position.Y);
|
||||||
|
spriteBatch.Draw(texture, drawPosition, Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user