我尝试javascript游戏模拟,如果5级游戏完成,该怎么办



程序正在运行,我希望如果它达到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();
    }
}
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 {
[...]

相关内容

最新更新