From 22d43dc0c13a48e567d3b1cc48275219cd6ec4fa Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Fri, 29 Aug 2025 03:43:10 +0100 Subject: [PATCH] figure out reason for the strange player/projectile alignment, and address it (when player is facing left, we want to subtract size of whole projectile so it looks like it starts at the leftmost side; however, when player is facing right, we want to add by the width of the player, so it looks like the projectile starts from the player's rightmost side) --- fcore/level/player/player-vec.sml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fcore/level/player/player-vec.sml b/fcore/level/player/player-vec.sml index 915f87b..bd48159 100644 --- a/fcore/level/player/player-vec.sml +++ b/fcore/level/player/player-vec.sml @@ -155,8 +155,9 @@ struct val playerVec = PlayerAttackStandRight.lerp (rx, ry, 3.0, windowWidth, windowHeight) - (* todo: why does 81 work to give perfect alignment? *) - val projX = x + 81 + (* adding playerWidth to x so that projectile starts from + * the rightmost pixel of the player *) + val projX = x + Constants.playerWidth val projY = y + (Constants.playerHeight div 3) val projX = (Real32.fromInt projX + xOffset) * ratio val projY = (Real32.fromInt projY + yOffset) * ratio @@ -172,6 +173,10 @@ struct val playerVec = PlayerAttackStandLeft.lerp (rx, ry, 3.0, windowWidth, windowHeight) + (* subtracting playerHeight from x because projectile + * is the same size as the playerHeight, and it looks like + * the projectile starts from player's leftmost side this way. + * *) val projX = x - Constants.playerHeight val projY = y + (Constants.playerHeight div 3) val projX = (Real32.fromInt projX + xOffset) * ratio