From 1b0ac7955e4f89168667d3abcd583c7c5c414d5d Mon Sep 17 00:00:00 2001
From: Honey Daram <150115430+honeyreddydaram@users.noreply.github.com>
Date: Wed, 30 Oct 2024 19:26:40 +0530
Subject: [PATCH 1/3] Update index.html
addition of hint button and high score display.
---
JS/Simon Says/index.html | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/JS/Simon Says/index.html b/JS/Simon Says/index.html
index eaf18df..d5a7457 100644
--- a/JS/Simon Says/index.html
+++ b/JS/Simon Says/index.html
@@ -5,6 +5,7 @@
Simon Says Game
+
Simon Says Game
@@ -20,6 +21,17 @@ Press any key to start the game
4
+
+
+
+
+
+
From 887743e81095d8cb238257565e3e2b42bc41eccd Mon Sep 17 00:00:00 2001
From: Honey Daram <150115430+honeyreddydaram@users.noreply.github.com>
Date: Wed, 30 Oct 2024 19:33:43 +0530
Subject: [PATCH 2/3] Update app.js
new changes added stating "//new"
---
JS/Simon Says/app.js | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/JS/Simon Says/app.js b/JS/Simon Says/app.js
index 94a0d4c..103ac8f 100644
--- a/JS/Simon Says/app.js
+++ b/JS/Simon Says/app.js
@@ -1,5 +1,8 @@
let gameSeq = [];
let userSeq = [];
+//new
+let highScore = 0;
+
let btns = ["yellow", "red", "purple", "green"];
@@ -7,6 +10,7 @@ let started = false;
let level = 0;
let h2 = document.querySelector("h2");
+let highScoreDisplay = document.querySelector(".highscore");
document.addEventListener("keypress", function () {
if (started == false) {
@@ -42,6 +46,17 @@ function levelUp() {
gameSeq.push(randColor);
console.log(gameSeq);
gameFlash(randBtn);
+ //new
+ resetHint();
+}
+//new
+function gameScoreDisplay(){
+ if (level === 0){
+ h2.innerHTML = `Game Over! Your score was ${level}
Press any key to start. `;
+ }else{
+ h2.innerHTML = `Game Over! Your score was ${level-1}
Press any key to start. `;
+ }
+
}
function checkAns(idx) {
@@ -50,12 +65,19 @@ function checkAns(idx) {
setTimeout(levelUp, 1000);
}
} else {
- h2.innerHTML = `Game Over! Your score was ${level}
Press any key to start.`;
+ gameScoreDisplay();
document.querySelector("body").style.backgroundColor = "red";
setTimeout(function () {
document.querySelector("body").style.backgroundColor = "white";
}, 150);
+ if (level-1 > highScore){
+ highScore = level-1;
+ highScoreDisplay.innerHTML = ` High Score: ${highScore}
`;
+
+ }
+
reset();
+ resetHint();
}
}
@@ -80,3 +102,13 @@ function reset() {
userSeq = [];
level = 0;
}
+//new
+function resetHint(){
+ hintBox.innerHTML="";
+}
+
+let hintBtn = document.querySelector(".hint");
+let hintBox = document.querySelector(".hintBox");
+hintBtn.addEventListener("click",function(){
+ hintBox.innerHTML=`${gameSeq}`
+});
From 8a658938a03a3df69432f56224b94478833db004 Mon Sep 17 00:00:00 2001
From: Honey Daram <150115430+honeyreddydaram@users.noreply.github.com>
Date: Wed, 30 Oct 2024 19:36:14 +0530
Subject: [PATCH 3/3] Update style.css
changes added for hint button and high score
---
JS/Simon Says/style.css | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/JS/Simon Says/style.css b/JS/Simon Says/style.css
index ec1ab8e..7774812 100644
--- a/JS/Simon Says/style.css
+++ b/JS/Simon Says/style.css
@@ -38,3 +38,35 @@ body {
.userflash {
background-color: green;
}
+/* new */
+.highscore{
+ height: 50px;
+ width: 300px;
+ /* border: 1px solid black; */
+ border-radius:25%;
+ margin: auto;
+ padding:auto;
+}
+
+.hintMain{
+ display:flex;
+ justify-content:center;
+ width:100px;
+ height:50px;
+}
+
+.hint{
+ background-color: yellow;
+ height: 30px;
+ width: 30px;
+ border-radius: 50%;
+ margin:auto;
+ padding: auto;
+ cursor: pointer;
+}
+
+.hintBox{
+ margin:auto;
+ /* padding: auto; */
+ width:60px;
+}