diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-01 19:45:33 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-01 19:45:33 -0700 |
commit | d08e0105cbc59c6cc804f04aaf1e4e625a13960c (patch) | |
tree | 57d5270e146ce2e0c5cfba30e172ab87a2210514 /src/engine/config/constants.ts | |
parent | a8d07a790395e14fe7aedd3ba638db466f9c0842 (diff) | |
download | the-abstraction-engine-d08e0105cbc59c6cc804f04aaf1e4e625a13960c.tar.gz the-abstraction-engine-d08e0105cbc59c6cc804f04aaf1e4e625a13960c.zip |
eyes follow cursor
Diffstat (limited to 'src/engine/config/constants.ts')
-rw-r--r-- | src/engine/config/constants.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/engine/config/constants.ts b/src/engine/config/constants.ts index a00a141..c2cbc76 100644 --- a/src/engine/config/constants.ts +++ b/src/engine/config/constants.ts @@ -1,3 +1,46 @@ +export enum Action { + MOVE_LEFT, + MOVE_RIGHT, + MOVE_UP, + MOVE_DOWN, + RESET, + INTERACT, +} + +export namespace KeyConstants { + export const KeyActions: Record<string, Action> = { + a: Action.MOVE_LEFT, + arrowleft: Action.MOVE_LEFT, + + d: Action.MOVE_RIGHT, + arrowright: Action.MOVE_RIGHT, + + w: Action.MOVE_UP, + arrowup: Action.MOVE_UP, + + s: Action.MOVE_DOWN, + arrowdown: Action.MOVE_DOWN, + + " ": Action.INTERACT, + enter: Action.INTERACT, + }; + + // value -> [key] from KeyActions + export const ActionKeys: Map<Action, string[]> = Object.keys( + KeyActions, + ).reduce((acc: Map<Action, string[]>, key) => { + const action = KeyActions[key.toLowerCase()]; + + if (acc.has(action)) { + acc.get(action)!.push(key); + return acc; + } + + acc.set(action, [key]); + return acc; + }, new Map()); +} + export namespace Miscellaneous { export const WIDTH = 800; export const HEIGHT = 800; |