From c99999c0c9996e0269ccefe7c023f45443aae8c6 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 18 Jan 2025 13:52:21 +0000 Subject: [PATCH] fix calculated distance for helpGetRightwardsPath (reused same distance calculate as in helpGetUpwardsPath before) --- fcore/enemy-behaviour.sml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fcore/enemy-behaviour.sml b/fcore/enemy-behaviour.sml index c26bcd5..c05053c 100644 --- a/fcore/enemy-behaviour.sml +++ b/fcore/enemy-behaviour.sml @@ -251,10 +251,13 @@ struct if isReachableFromRight (prevPlat, currentPlat) then (* is reachable, so reach *) let - val {y = cy, ...} = currentPlat - val {y = py, ...} = prevPlat + (* considering horizontal distance only. + * todo: can consider diagonal/vertical distance too + * (by pythagoras) *) + val {x = cx, ...} = currentPlat + val {x = px, ...} = prevPlat - val diff = py - cy + val diff = cx - px val platDist = dist + diff val (newDist, newPath) = getRightwardsPath @@ -405,6 +408,10 @@ struct else let val currentPlat = Platform.find (id, platforms) + (* considering vertical distance only. + * This is okay because the scan box is a simple square + * directly above prev platform which does not care about + * top right or top left). *) val {y = cy, ...} = currentPlat val {y = py, ...} = prevPlat