about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-04-13 10:51:05 -0400
committerelioat <elioat@tilde.institute>2024-04-13 10:51:05 -0400
commitbfc3d1d29278d286677aba7e75dbae3dc43bc193 (patch)
tree0d226e6f702f8d696c7c361dcacf3a8ad9da1ef8
parent5b57fd2e6418931a3be5274bd4ee20f5ebfefa3d (diff)
downloadtour-bfc3d1d29278d286677aba7e75dbae3dc43bc193.tar.gz
*
-rw-r--r--js/sand/sand.js14
1 files changed, 3 insertions, 11 deletions
diff --git a/js/sand/sand.js b/js/sand/sand.js
index b2dbb03..d241079 100644
--- a/js/sand/sand.js
+++ b/js/sand/sand.js
@@ -102,17 +102,9 @@ window.addEventListener('keydown', (e) => {
                     grid[y][x] = 0;
                     grid[y][x + 1] = 3;
                     return;
-                } else if ((e.key === ' ' || e.key === 'ArrowUp' || e.key === 'w') && (y === gridHeight - 1 || grid[y + 1][x] !== 0)) {
-                    let jumpCount = 0;
-                    function jump() {
-                        if (jumpCount < jumpHeight && y - jumpCount >= 0 && grid[y - jumpCount - 1][x] === 0) {
-                            grid[y - jumpCount][x] = 0;
-                            grid[y - jumpCount - 1][x] = 3;
-                            jumpCount++;
-                            setTimeout(jump, 100); // delay in milliseconds
-                        }
-                    }
-                    jump();
+                } else if ((e.key === ' ' || e.key === 'ArrowUp' || e.key === 'w') && y < gridHeight - 1 && grid[y + 1][x] !== 0) {
+                    grid[y][x] = 0;
+                    grid[Math.max(y - jumpHeight, 0)][x] = 3;
                     return;
                 }
             }