summary refs log tree commit diff stats
path: root/src/direction.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-03-01 22:19:46 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-03-01 22:19:46 -0500
commit7fa69be4e88f1fcf057871fec7e4503f50578465 (patch)
tree70a01aafe4092c29c112f72895494dbfa2033496 /src/direction.h
parentd8e7d815c197c5477678d835038dc3ff86c2a7e8 (diff)
downloadtanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.tar.gz
tanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.tar.bz2
tanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.zip
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.
Diffstat (limited to 'src/direction.h')
-rw-r--r--src/direction.h17
1 files changed, 17 insertions, 0 deletions
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) {
90 } 90 }
91} 91}
92 92
93inline Direction cardinalDirectionFacingPoint(vec2i point) {
94 double theta = atan2(point.y(), point.x());
95 theta /= M_PI;
96
97 if (theta < -3.0/4.0) {
98 return Direction::left;
99 } else if (theta < -1.0/4.0) {
100 return Direction::down;
101 } else if (theta < 1.0/4.0) {
102 return Direction::right;
103 } else if (theta < 3.0/4.0) {
104 return Direction::up;
105 } else {
106 return Direction::left;
107 }
108}
109
93#endif /* end of include guard: DIRECTION_H_AB66A90E */ 110#endif /* end of include guard: DIRECTION_H_AB66A90E */