Bug Fix: Set player positions to snap to integer values to fix pixel distortion.

This commit is contained in:
J. M. Ellis
2024-05-25 09:35:11 -07:00
parent 9ccb35f2ad
commit 5ad35d1927
2 changed files with 16 additions and 9 deletions
+7 -5
View File
@@ -23,7 +23,7 @@ namespace LunaLightXMG
private float vspJump; // Jump speed
// Player position
public Vector2 Position;
public Vector2 position;
// Constructor to initialize variables
public Player()
@@ -45,7 +45,7 @@ namespace LunaLightXMG
vspMaxWall = 5f;
vspJump = -10f;
Position = new Vector2(163, 63); // Initialize player position
position = new Vector2(163, 63); // Initialize player position
}
// Update method to handle movement logic
@@ -54,8 +54,8 @@ namespace LunaLightXMG
Movement(input);
// Update player position based on speed
Position.X += hsp;
Position.Y += vsp;
position.X += hsp;
position.Y += vsp;
}
private void Movement(PlayerInput input)
@@ -111,7 +111,9 @@ namespace LunaLightXMG
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);
}
}