allow player to have a different width/height that is not a perfect square, (now we have Constants.playerWidth and Constants.playerHeight, having deleted the previous size in Constants.playerSize)

This commit is contained in:
2025-02-18 12:31:22 +00:00
parent e62493ce56
commit d3200745d0
7 changed files with 270 additions and 88 deletions

View File

@@ -3,35 +3,6 @@ struct
open EnemyType
open EntityType
(* if player is attacking, does enemy collide with attack? *)
fun isCollidingWithPlayerAttack (player: PlayerType.player, enemy: enemy) =
let
val {x = px, y = py, facing, mainAttack, ...} = player
val pSize = Constants.playerSize
val {x = ex, y = ey, ...} = enemy
val eSize = Constants.enemySize
in
case mainAttack of
PlayerType.MAIN_ATTACKING {length, ...} =>
(case facing of
FACING_RIGHT =>
let
val px = px + pSize
in
Collision.isCollidingPlus
(px, py, length, pSize, ex, ey, eSize, eSize)
end
| FACING_LEFT =>
let
val px = px - length
in
Collision.isCollidingPlus
(px, py, length, pSize, ex, ey, eSize, eSize)
end)
| _ => false
end
fun canWalkAhead (x, y, wallTree, platformTree) =
let
val y = y + Constants.enemySize - 5
@@ -351,8 +322,8 @@ struct
fun isInFollowRange (player, enemy) =
let
val {x = px, y = py, ...} = player
val pfx = px + Constants.playerSize
val pfy = py + Constants.playerSize
val pfx = px + Constants.playerWidth
val pfy = py + Constants.playerHeight
val range = 199