diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-03-05 20:50:51 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-03-05 20:50:51 -0500 |
commit | 1c462ef3780b33468ed93dde3ab6178765807ffe (patch) | |
tree | 6ee2f34ed3514c10d146c91b0e8e935cf9d1ccb6 /src/direction.h | |
parent | 937875c4e1432b418f0f5051759e02c8d4c9ffa4 (diff) | |
download | tanetane-1c462ef3780b33468ed93dde3ab6178765807ffe.tar.gz tanetane-1c462ef3780b33468ed93dde3ab6178765807ffe.tar.bz2 tanetane-1c462ef3780b33468ed93dde3ab6178765807ffe.zip |
Added MirrorSystem
This is really just for letting one sprite mirror another's movement and animation. I tried doing it in the BehaviourSystem, but you get stuttering if you do it earlier in the loop than the CharacterSystem, so I ended up having to make a new system just for this thing that will not happen very often.
Diffstat (limited to 'src/direction.h')
-rw-r--r-- | src/direction.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/direction.h b/src/direction.h index 432f7a9..325bcaf 100644 --- a/src/direction.h +++ b/src/direction.h | |||
@@ -65,6 +65,19 @@ inline Direction oppositeDirection(Direction value) { | |||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | inline Direction directionMirroredVertically(Direction value) { | ||
69 | switch (value) { | ||
70 | case Direction::up: return Direction::down; | ||
71 | case Direction::up_right: return Direction::down_right; | ||
72 | case Direction::right: return Direction::right; | ||
73 | case Direction::down_right: return Direction::up_right; | ||
74 | case Direction::down: return Direction::up; | ||
75 | case Direction::down_left: return Direction::up_left; | ||
76 | case Direction::left: return Direction::left; | ||
77 | case Direction::up_left: return Direction::down_left; | ||
78 | } | ||
79 | } | ||
80 | |||
68 | inline Direction directionFacingPoint(vec2i point) { | 81 | inline Direction directionFacingPoint(vec2i point) { |
69 | double theta = atan2(-point.y(), point.x()); | 82 | double theta = atan2(-point.y(), point.x()); |
70 | theta /= M_PI; | 83 | theta /= M_PI; |