Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High Score Feature Addition and fixed final score problem #93

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion JS/Simon Says/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let gameSeq = [];
let userSeq = [];
let hs = 0;

let btns = ["yellow", "red", "purple", "green"];

Expand Down Expand Up @@ -50,11 +51,11 @@ function checkAns(idx) {
setTimeout(levelUp, 1000);
}
} else {
h2.innerHTML = `Game Over! Your score was <b>${level}</b> <br> Press any key to start.`;
document.querySelector("body").style.backgroundColor = "red";
setTimeout(function () {
document.querySelector("body").style.backgroundColor = "white";
}, 150);
hiscore(level);
reset();
}
}
Expand All @@ -80,3 +81,11 @@ function reset() {
userSeq = [];
level = 0;
}


function hiscore(level)
{
if(level>hs)
hs=level;
h2.innerHTML = `Game Over! Your score was <b>${level - 1}</b> <br> High-Score: <b>${hs-1}</b> <br> Press any key to start.`;
}