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)

This commit is contained in:
2025-08-29 03:43:10 +01:00
parent e3972fab81
commit 22d43dc0c1

View File

@@ -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