From d08e0105cbc59c6cc804f04aaf1e4e625a13960c Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 1 Mar 2024 19:45:33 -0700 Subject: eyes follow cursor --- src/engine/config/constants.ts | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/engine/config/constants.ts') 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 = { + 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 = Object.keys( + KeyActions, + ).reduce((acc: Map, 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; -- cgit v1.2.3-70-g09d2