程序正在运行,我想如果它达到5级,游戏结束。 这个项目:https://codepen.io/alfiansyah/pen/bPbZjj
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");
setTimeout(function() {
$("body").removeClass("game-over");
}, 200);
startOver();
}
}
答案 0 :(得分:-1)
if (gamePattern[currentLevel] === userClickedPattern[currentLevel]) {
if (userClickedPattern.length === gamePattern.length) {
if (gamePattern.length < 5) { // Check level
setTimeout(function() {
nextSequence();
}, 1000);
} else {
// Level 5 reached
}
}
} else {
[...]