summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-03-01 22:21:20 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-03-01 22:21:20 -0500
commit0eba4430608fce20ed8530ebf7790a2fcffae26c (patch)
treec2a9d9b78af9da9af9b9cc3a518c1c63c73c3308
parent7fa69be4e88f1fcf057871fec7e4503f50578465 (diff)
downloadtanetane-0eba4430608fce20ed8530ebf7790a2fcffae26c.tar.gz
tanetane-0eba4430608fce20ed8530ebf7790a2fcffae26c.tar.bz2
tanetane-0eba4430608fce20ed8530ebf7790a2fcffae26c.zip
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.
-rw-r--r--src/direction.h4
1 files changed, 2 insertions, 2 deletions
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) {
66} 66}
67 67
68inline Direction directionFacingPoint(vec2i point) { 68inline Direction directionFacingPoint(vec2i point) {
69 double theta = atan2(point.y(), point.x()); 69 double theta = atan2(-point.y(), point.x());
70 theta /= M_PI; 70 theta /= M_PI;
71 71
72 if (theta < -7.0/8.0) { 72 if (theta < -7.0/8.0) {
@@ -91,7 +91,7 @@ inline Direction directionFacingPoint(vec2i point) {
91} 91}
92 92
93inline Direction cardinalDirectionFacingPoint(vec2i point) { 93inline Direction cardinalDirectionFacingPoint(vec2i point) {
94 double theta = atan2(point.y(), point.x()); 94 double theta = atan2(-point.y(), point.x());
95 theta /= M_PI; 95 theta /= M_PI;
96 96
97 if (theta < -3.0/4.0) { 97 if (theta < -3.0/4.0) {