From cb620971506d01216a9a4d02946b1259388af048 Mon Sep 17 00:00:00 2001 From: "Kacper Kostka (aider)" Date: Sat, 5 Apr 2025 18:36:27 +0200 Subject: [PATCH] fix: Stretch player sprite to match collision box height and remove levitation --- js/entities/player.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/entities/player.js b/js/entities/player.js index c04dd76..82d60c4 100644 --- a/js/entities/player.js +++ b/js/entities/player.js @@ -139,12 +139,13 @@ class Player extends Entity { // Draw the correct sprite frame // Center the sprite on the entity position, with y-offset to align feet with collision box + // Stretch the sprite vertically to match the collision box height ctx.drawImage( this.sprite, this.currentFrame * this.frameWidth, 0, this.frameWidth, this.frameHeight, - -spriteDisplayWidth / 2, -spriteDisplayHeight / 2 - 2, // Adjusted y-offset to align with collision box - spriteDisplayWidth, spriteDisplayHeight + -spriteDisplayWidth / 2, -spriteDisplayHeight / 2, // Remove the negative offset that caused levitation + spriteDisplayWidth, spriteDisplayHeight * 1.2 // Stretch sprite vertically by 20% to match collision box ); ctx.restore(); @@ -167,9 +168,9 @@ class Player extends Entity { ctx.lineWidth = 1; ctx.strokeRect( screenX - spriteDisplayWidth / 2, - screenY - spriteDisplayHeight / 2 - 2, // Match the sprite drawing offset + screenY - spriteDisplayHeight / 2, // Match the updated sprite drawing position spriteDisplayWidth, - spriteDisplayHeight + spriteDisplayHeight * 1.2 // Match the stretched sprite height ); // Draw a dot at the entity's exact position