summaryrefslogtreecommitdiff
path: root/src/engine/interfaces
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-01 19:45:33 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-01 19:45:33 -0700
commitd08e0105cbc59c6cc804f04aaf1e4e625a13960c (patch)
tree57d5270e146ce2e0c5cfba30e172ab87a2210514 /src/engine/interfaces
parenta8d07a790395e14fe7aedd3ba638db466f9c0842 (diff)
downloadthe-abstraction-engine-d08e0105cbc59c6cc804f04aaf1e4e625a13960c.tar.gz
the-abstraction-engine-d08e0105cbc59c6cc804f04aaf1e4e625a13960c.zip
eyes follow cursor
Diffstat (limited to 'src/engine/interfaces')
-rw-r--r--src/engine/interfaces/Direction.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/engine/interfaces/Direction.ts b/src/engine/interfaces/Direction.ts
index c2e2c1e..6f19367 100644
--- a/src/engine/interfaces/Direction.ts
+++ b/src/engine/interfaces/Direction.ts
@@ -5,3 +5,15 @@ export enum Direction {
RIGHT = "RIGHT",
NONE = "NONE",
}
+
+export const angleToDirection = (angle: number): Direction => {
+ if (angle >= -Math.PI / 4 && angle < Math.PI / 4) {
+ return Direction.RIGHT;
+ } else if (angle >= Math.PI / 4 && angle < (3 * Math.PI) / 4) {
+ return Direction.DOWN;
+ } else if (angle >= (3 * Math.PI) / 4 || angle < -(3 * Math.PI) / 4) {
+ return Direction.LEFT;
+ } else {
+ return Direction.UP;
+ }
+};