From f5071a953b30fa1ef79603ee1e6c8e38c099d9c4 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 6 Feb 2025 17:42:45 +0000 Subject: [PATCH] make sure playedr only checks collisions with enemy in the case that player was previously attacked --- fcore/player.sml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/fcore/player.sml b/fcore/player.sml index 6af92f9..0a36379 100644 --- a/fcore/player.sml +++ b/fcore/player.sml @@ -406,18 +406,23 @@ struct (player, walls, wallTree, platforms, platformTree) val player = PlayerPatch.withPatches (player, patches) - (* player reaction to collisions with enemies *) - val patches = - let - val {x, y, ...} = player - val size = Constants.playerSize - val env = (#enemies game, player) - val state = [] - in - FoldEnemies.foldRegion (x, y, size, size, env, state, enemyTree) - end in - PlayerPatch.withPatches (player, 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 + val {x, y, ...} = player + val size = Constants.playerSize + val env = (#enemies game, player) + val state = [] + val patches = FoldEnemies.foldRegion + (x, y, size, size, env, state, enemyTree) + in + PlayerPatch.withPatches (player, patches) + end end (* todo: add attacked enemies to player's 'enemies' field *)