From 6d7669ac10df32f38c13cb44ca3bf3ffe35f9db3 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Sat, 20 Dec 2025 13:12:56 -0800 Subject: [PATCH] Stop reading keys after collisions until a keyup event --- html/images/space.svg | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/html/images/space.svg b/html/images/space.svg index 9c0ca19..fdcacac 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -215,7 +215,6 @@ const det = (+xb - +xa) * (+yc - +ya) - (+xc - +xa) * (+yb - +ya); const pos = `${positionX},${positionY}`; - const cwOrientation = det < 0; const isClockwise = det < 0; let isAcute = false; @@ -494,25 +493,8 @@ let rotateCWPressed = false; let rotateCCWPressed = false; - const pressed = [ - spacePressed, - upPressed, - downPressed, - leftPressed, - rightPressed, - rotateCWPressed, - rotateCCWPressed, - ]; - - document.addEventListener("keydown", function(e) { - // console.log(isReadingKeys, pressed.every(k => k)); - - if (!isReadingKeys && pressed.some(k => k)) { - return; - } else { - isReadingKeys = true; - } + if (!isReadingKeys) return; if (!started && !restart) { started = true; @@ -575,6 +557,8 @@ }); document.addEventListener("keyup", function(e) { + isReadingKeys = true; + switch (e.code) { case "Space": spacePressed = false;