From 95380c624ac86671eb48a946c3066ba3dc2c6a54 Mon Sep 17 00:00:00 2001 From: Sam cook Date: Tue, 13 Jan 2026 17:01:36 +0000 Subject: [PATCH 1/5] add dist/node_modules to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f78ec928..8514f353 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .parcel-cache +/dist +/node_modules From a45290be56d5cc2ab7fbabc75a2d534f4cd70e7e Mon Sep 17 00:00:00 2001 From: Sam cook Date: Tue, 13 Jan 2026 17:01:54 +0000 Subject: [PATCH 2/5] update package-lock with peer:true --- package-lock.json | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7f43490..c95b3b01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -372,6 +372,7 @@ "integrity": "sha512-SRZFtqGiaKHlZ2YAvf+NHvBFWS3GnkBvJMfOJM7kxJRK3M1bhbwJa/GgSdzqro5UVf9Bfj6E+pkdrRQIOZ7jMQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@mischnic/json-sourcemap": "^0.1.0", "@parcel/cache": "2.13.3", @@ -2024,6 +2025,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001688", "electron-to-chromium": "^1.5.73", @@ -3256,21 +3258,6 @@ "node": ">=10" } }, - "node_modules/srcset": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/srcset/-/srcset-5.0.1.tgz", - "integrity": "sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", From c79559d7ae83f657cbc80ed18a34721c6c6e3822 Mon Sep 17 00:00:00 2001 From: Sam cook Date: Thu, 15 Jan 2026 17:09:53 +0000 Subject: [PATCH 3/5] update version and removed one space in code --- package-lock.json | 6 +++--- src/index.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index c95b3b01..ff91a369 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2050,9 +2050,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001696", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001696.tgz", - "integrity": "sha512-pDCPkvzfa39ehJtJ+OwGT/2yvT2SbjfHhiIW2LWOAcMQ7BzwxT/XuyUp4OTOd0XFWA6BKw0JalnBHgSi5DGJBQ==", + "version": "1.0.30001764", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001764.tgz", + "integrity": "sha512-9JGuzl2M+vPL+pz70gtMF9sHdMFbY9FJaQBi186cHKH3pSzDvzoUJUPV6fqiKIMyXbud9ZLg4F3Yza1vJ1+93g==", "dev": true, "funding": [ { diff --git a/src/index.html b/src/index.html index 03dc6b10..f9592364 100755 --- a/src/index.html +++ b/src/index.html @@ -116,7 +116,7 @@ -
+
From 4536321925f9c925e5f2e58e10e09569cc5a9d44 Mon Sep 17 00:00:00 2001 From: Sam cook Date: Thu, 15 Jan 2026 17:21:13 +0000 Subject: [PATCH 4/5] ctrl s to sync lines --- src/index.html | 247 +++++++++++++++++++++++++------------------------ 1 file changed, 124 insertions(+), 123 deletions(-) diff --git a/src/index.html b/src/index.html index f9592364..81e65a42 100755 --- a/src/index.html +++ b/src/index.html @@ -1,7 +1,8 @@ - - - - JavaScript Snake - - - - - - -
-
- Theme: - -
-
- Mode: - -
+ --> + + + +
+
+ Theme: + +
+
+ Mode: + +
+
-
+ +
-
+
-
- - - + + + - document.getElementById('go_full_screen').addEventListener('click', go_full_screen); - - - + \ No newline at end of file From 8735a2676b652373103d01d569143bdb06658a71 Mon Sep 17 00:00:00 2001 From: Sam cook Date: Thu, 15 Jan 2026 17:59:59 +0000 Subject: [PATCH 5/5] add instructions --- src/index.html | 3 ++- src/js/snake.js | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/index.html b/src/index.html index 81e65a42..43fcff94 100755 --- a/src/index.html +++ b/src/index.html @@ -116,7 +116,8 @@
- + +
diff --git a/src/js/snake.js b/src/js/snake.js index 6232e8d9..f19fbb62 100644 --- a/src/js/snake.js +++ b/src/js/snake.js @@ -249,8 +249,8 @@ SNAKE.Snake = if (me.snakeLength > highScore) { alert( "Congratulations! You have beaten your previous high score, which was " + - highScore + - ".", + highScore + + ".", ); localStorage.setItem(HIGH_SCORE_KEY, me.snakeLength); } @@ -310,7 +310,7 @@ SNAKE.Snake = if (isDead || (isPaused && !config.premoveOnPause)) { return; } - + // mark line here let directionFound = MOVE_NONE; switch (keyNum) { @@ -338,6 +338,7 @@ SNAKE.Snake = * This method is executed for each move of the snake. It determines where the snake will go and what will happen to it. This method needs to run quickly. * @method go */ + // here me.go = function () { const oldHead = me.snakeHead, newHead = me.snakeTail, @@ -760,17 +761,17 @@ SNAKE.Board = // defaults if (!config.onLengthUpdate) { - config.onLengthUpdate = () => {}; + config.onLengthUpdate = () => { }; } if (!config.onPauseToggle) { - config.onPauseToggle = () => {}; + config.onPauseToggle = () => { }; } if (!config.onWin) { - config.onWin = () => {}; + config.onWin = () => { }; } if (!config.onDeath) { - config.onDeath = () => {}; + config.onDeath = () => { }; } let myFood, @@ -1409,3 +1410,12 @@ SNAKE.Board = } }; // end return function })(); + +let InstructionBtn = document.getElementById("instruction_btn"); +function instructions() { + if (typeof mySnakeBoard !== "undefined" && mySnakeBoard.getBoardState() !== BOARD_NOT_READY) { + mySnakeBoard.setPaused(!mySnakeBoard.getPaused()); + } +} +InstructionBtn.addEventListener("click", instructions); +// The pause screen text is set at snake.js:827. You can change it there to update what's displayed when paused. For example: \ No newline at end of file