Skip to content

Commit

Permalink
Merge pull request #701 from SreejaVeerappan/patch-28
Browse files Browse the repository at this point in the history
Update game.js
  • Loading branch information
Ayushparikh-code authored Oct 29, 2024
2 parents e1c7e42 + d90a0fa commit cd4aefa
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Simon_Game/game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var buttonColours = ["red", "blue", "green", "yellow"];

var gamePattern = [];
Expand Down Expand Up @@ -28,23 +27,23 @@ $(".btn").click(function() {

function checkAnswer(currentLevel) {

if (gamePattern[currentLevel] === userClickedPattern[currentLevel]) {
if (userClickedPattern.length === gamePattern.length){
setTimeout(function () {
nextSequence();
}, 1000);
}
} else {
playSound("wrong");
$("body").addClass("game-over");
$("#level-title").text("Game Over, Press Any Key to Restart");

if (userClickedPattern.length > 0 && gamePattern[currentLevel] === userClickedPattern[currentLevel]) {
if (userClickedPattern.length === gamePattern.length){
setTimeout(function () {
$("body").removeClass("game-over");
}, 200);

startOver();
nextSequence();
}, 1000);
}
} else {
playSound("wrong");
$("body").addClass("game-over");
$("#level-title").text("Game Over, Press Any Key to Restart");

setTimeout(function () {
$("body").removeClass("game-over");
}, 200);

startOver();
}
}


Expand Down Expand Up @@ -77,5 +76,3 @@ function startOver() {
gamePattern = [];
started = false;
}


0 comments on commit cd4aefa

Please sign in to comment.