From 0eba4430608fce20ed8530ebf7790a2fcffae26c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 1 Mar 2021 22:21:20 -0500 Subject: Fixed inverted Y coordinate of directionFacingPoint functions It's because the game's coordinate system has Y increasing downward, whereas the coordinate system used by the trig functions has Y increasing upward. --- src/direction.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/direction.h b/src/direction.h index 595693f..432f7a9 100644 --- a/src/direction.h +++ b/src/direction.h @@ -66,7 +66,7 @@ inline Direction oppositeDirection(Direction value) { } inline Direction directionFacingPoint(vec2i point) { - double theta = atan2(point.y(), point.x()); + double theta = atan2(-point.y(), point.x()); theta /= M_PI; if (theta < -7.0/8.0) { @@ -91,7 +91,7 @@ inline Direction directionFacingPoint(vec2i point) { } inline Direction cardinalDirectionFacingPoint(vec2i point) { - double theta = atan2(point.y(), point.x()); + double theta = atan2(-point.y(), point.x()); theta /= M_PI; if (theta < -3.0/4.0) { -- cgit 1.4.1