From 7fa69be4e88f1fcf057871fec7e4503f50578465 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 1 Mar 2021 22:19:46 -0500 Subject: Started writing the Mixolydia scene! Looking pretty good so far. TODO: direction facing functions have inverted Y coordinate. confusion expression doesn't exist yet. rest of scene. --- src/direction.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/direction.h') diff --git a/src/direction.h b/src/direction.h index 3dd95f9..595693f 100644 --- a/src/direction.h +++ b/src/direction.h @@ -90,4 +90,21 @@ inline Direction directionFacingPoint(vec2i point) { } } +inline Direction cardinalDirectionFacingPoint(vec2i point) { + double theta = atan2(point.y(), point.x()); + theta /= M_PI; + + if (theta < -3.0/4.0) { + return Direction::left; + } else if (theta < -1.0/4.0) { + return Direction::down; + } else if (theta < 1.0/4.0) { + return Direction::right; + } else if (theta < 3.0/4.0) { + return Direction::up; + } else { + return Direction::left; + } +} + #endif /* end of include guard: DIRECTION_H_AB66A90E */ -- cgit 1.4.1