From 8c1ab4c5756ac43d52bc8773f5e72dde90f79e77 Mon Sep 17 00:00:00 2001 From: Joris Date: Tue, 5 Jul 2022 22:11:00 +0200 Subject: WIP --- src/controls.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/controls.ts') diff --git a/src/controls.ts b/src/controls.ts index b575b3f..8ae0dbf 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -3,7 +3,7 @@ export interface Controls { right: boolean, down: boolean, left: boolean, - space: boolean, + spaceCount: number, } export let current = { @@ -11,7 +11,7 @@ export let current = { right: false, down: false, left: false, - space: false, + spaceCount: 0, } document.addEventListener('keydown', event => { @@ -31,8 +31,8 @@ function update(current: Controls, key: string, isDown: boolean): Controls { return { ...current, down: isDown } else if (key === 'ArrowLeft') return { ...current, left: isDown } - else if (key === ' ') - return { ...current, space: isDown } + else if (key === ' ' && !isDown) + return { ...current, spaceCount: current.spaceCount + 1 } else return current } -- cgit v1.2.3