diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-12-24 20:13:47 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-12-24 20:28:51 +0100 |
commit | 764cd8344df2dc9b2c271d868ae193b98b829af7 (patch) | |
tree | 026b23d62d5fc7df338f880e85c26459f8be1a6a /src/renderer/runtime/view/input | |
parent | 2f77cf7b7484beb3b94900f95d61fd2685c42ac2 (diff) | |
download | rpgedit-764cd8344df2dc9b2c271d868ae193b98b829af7.tar rpgedit-764cd8344df2dc9b2c271d868ae193b98b829af7.zip |
Fix lint issues
Diffstat (limited to 'src/renderer/runtime/view/input')
-rw-r--r-- | src/renderer/runtime/view/input/gameinput.ts | 26 | ||||
-rw-r--r-- | src/renderer/runtime/view/input/inputhandler.ts | 12 |
2 files changed, 12 insertions, 26 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', diff --git a/src/renderer/runtime/view/input/inputhandler.ts b/src/renderer/runtime/view/input/inputhandler.ts index 17abfe6..4f5f150 100644 --- a/src/renderer/runtime/view/input/inputhandler.ts +++ b/src/renderer/runtime/view/input/inputhandler.ts @@ -7,26 +7,22 @@ export class InputHandler extends Listenable<[string, boolean]> { super(); window.addEventListener('keydown', (ev) => { - if (!relevantKeys.has(ev.code)) - return; + if (!relevantKeys.has(ev.code)) return; ev.preventDefault(); - if (ev.repeat) - return; + if (ev.repeat) return; this.keys.add(ev.code); this.runListeners(ev.code, true); }); window.addEventListener('keyup', (ev) => { - if (!relevantKeys.has(ev.code)) - return; + if (!relevantKeys.has(ev.code)) return; ev.preventDefault(); - if (!this.keys.has(ev.code)) - return; + if (!this.keys.has(ev.code)) return; this.keys.delete(ev.code); this.runListeners(ev.code, false); |