make sure playedr only checks collisions with enemy in the case that player was previously attacked

This commit is contained in:
2025-02-06 17:42:45 +00:00
parent e1e20230d6
commit f5071a953b

View File

@@ -406,19 +406,24 @@ struct
(player, walls, wallTree, platforms, platformTree) (player, walls, wallTree, platforms, platformTree)
val player = PlayerPatch.withPatches (player, patches) val player = PlayerPatch.withPatches (player, patches)
(* player reaction to collisions with enemies *) in
val patches = (* player reaction to collisions with enemies.
* We only detect collisions if player is not in invincibility period
* after being previously attacked. *)
case #attacked player of
ATTACKED _ => player
| _ =>
let let
val {x, y, ...} = player val {x, y, ...} = player
val size = Constants.playerSize val size = Constants.playerSize
val env = (#enemies game, player) val env = (#enemies game, player)
val state = [] val state = []
in val patches = FoldEnemies.foldRegion
FoldEnemies.foldRegion (x, y, size, size, env, state, enemyTree) (x, y, size, size, env, state, enemyTree)
end
in in
PlayerPatch.withPatches (player, patches) PlayerPatch.withPatches (player, patches)
end end
end
(* todo: add attacked enemies to player's 'enemies' field *) (* todo: add attacked enemies to player's 'enemies' field *)
fun concatAttackedEnemies (player: player, enemyCollisions) = fun concatAttackedEnemies (player: player, enemyCollisions) =