From 6ad522a79d3d116baf5b2a7267584170e98ce3f8 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 13 Dec 2022 17:58:32 +0100 Subject: [PATCH] Input system fix --- assets/Scripts/Game/Input/KeyboardInput.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/assets/Scripts/Game/Input/KeyboardInput.ts b/assets/Scripts/Game/Input/KeyboardInput.ts index cf42fbf..1b6faec 100644 --- a/assets/Scripts/Game/Input/KeyboardInput.ts +++ b/assets/Scripts/Game/Input/KeyboardInput.ts @@ -27,16 +27,16 @@ export class KeyboardInput implements IInput { private onKeyDown(event: EventKeyboard): void { switch (event.keyCode) { case this.up: - this.yAxis += 1; + this.yAxis = 1; break; case this.down: - this.yAxis += -1; + this.yAxis = -1; break; case this.left: - this.xAxis += -1; + this.xAxis = -1; break; case this.right: - this.xAxis += 1; + this.xAxis = 1; break; } } @@ -44,16 +44,16 @@ export class KeyboardInput implements IInput { private onKeyUp(event: EventKeyboard): void { switch (event.keyCode) { case this.up: - this.yAxis -= 1; + this.yAxis = this.yAxis === 1 ? 0 : this.yAxis; break; case this.down: - this.yAxis -= -1; + this.yAxis = this.yAxis === -1 ? 0 : this.yAxis; break; case this.left: - this.xAxis -= -1; + this.xAxis = this.xAxis === -1 ? 0 : this.xAxis; break; case this.right: - this.xAxis -= 1; + this.xAxis = this.xAxis === 1 ? 0 : this.xAxis; break; } }