From 38f89d9ebdd6f31f1b9103c086d49f0a953786f1 Mon Sep 17 00:00:00 2001
From: KaurTatinder <9780tatinder@gmail.com>
Date: Wed, 19 Feb 2025 19:10:00 -0700
Subject: [PATCH 1/2] Update snake.js
---
src/js/snake.js | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/js/snake.js b/src/js/snake.js
index 6232e8d9..edeb129c 100644
--- a/src/js/snake.js
+++ b/src/js/snake.js
@@ -244,17 +244,19 @@ SNAKE.Snake =
blockPool[blockPool.length] = tempBlock;
}
- function recordScore() {
- const highScore = localStorage[HIGH_SCORE_KEY];
- if (me.snakeLength > highScore) {
- alert(
- "Congratulations! You have beaten your previous high score, which was " +
- highScore +
- ".",
- );
- localStorage.setItem(HIGH_SCORE_KEY, me.snakeLength);
+ function recordScore() {
+ const highScore = localStorage[HIGH_SCORE_KEY] || 0; // Ensure highScore is defined
+ if (me.snakeLength > highScore) {
+ // Update the UI instead of using alert
+ const messageBox = document.getElementById("score-message");
+ if (messageBox) {
+ messageBox.textContent = `Congratulations! You have beaten your previous high score, which was ${highScore}.`;
+ messageBox.style.display = "block"; // Make sure the message is visible
}
- }
+ localStorage.setItem(HIGH_SCORE_KEY, me.snakeLength);
+ }
+}
+
function handleEndCondition(handleFunc) {
recordScore();
From bacf365f8c71e98611b9da8cb1060c384ea72e07 Mon Sep 17 00:00:00 2001
From: KaurTatinder <9780tatinder@gmail.com>
Date: Wed, 19 Feb 2025 19:19:10 -0700
Subject: [PATCH 2/2] Update index.html
---
src/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/index.html b/src/index.html
index 03dc6b10..8f259b42 100755
--- a/src/index.html
+++ b/src/index.html
@@ -118,7 +118,7 @@
-
+