summaryrefslogtreecommitdiffstats
path: root/src/renderer/runtime/view/input/gameinput.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/runtime/view/input/gameinput.ts')
-rw-r--r--src/renderer/runtime/view/input/gameinput.ts26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/renderer/runtime/view/input/gameinput.ts b/src/renderer/runtime/view/input/gameinput.ts
index 67fbe0c..b116839 100644
--- a/src/renderer/runtime/view/input/gameinput.ts
+++ b/src/renderer/runtime/view/input/gameinput.ts
@@ -35,13 +35,8 @@ export class GameInputHandler extends Listenable<[GameInput]> {
super();
this.input = new InputHandler(
- new Set([
- 'ArrowLeft',
- 'ArrowUp',
- 'ArrowRight',
- 'ArrowDown',
- ...Object.keys(buttonMapping),
- ]));
+ new Set(['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown', ...Object.keys(buttonMapping)]),
+ );
this.input.addListener((key: string, pressed: boolean) => {
const button = buttonMapping[key];
@@ -57,17 +52,12 @@ export class GameInputHandler extends Listenable<[GameInput]> {
const dir = vec2.create();
- if (this.input.has('ArrowLeft'))
- vec2.add(dir, dir, [-1, 0]);
- if (this.input.has('ArrowUp'))
- vec2.add(dir, dir, [0, -1]);
- if (this.input.has('ArrowRight'))
- vec2.add(dir, dir, [1, 0]);
- if (this.input.has('ArrowDown'))
- vec2.add(dir, dir, [0, 1]);
-
- if (vec2.sqrLen(dir) > 0)
- vec2.normalize(dir, dir);
+ if (this.input.has('ArrowLeft')) vec2.add(dir, dir, [-1, 0]);
+ if (this.input.has('ArrowUp')) vec2.add(dir, dir, [0, -1]);
+ if (this.input.has('ArrowRight')) vec2.add(dir, dir, [1, 0]);
+ if (this.input.has('ArrowDown')) vec2.add(dir, dir, [0, 1]);
+
+ if (vec2.sqrLen(dir) > 0) vec2.normalize(dir, dir);
this.runListeners({
type: 'direction',