I'm facing a challenge with setting up an end screen for my candy crush game. I have implemented a timer, but when the time runs out and certain conditions are met, the end screen fails to appear. Do you know what might be causing this issue?
function timer() {
var seconds = 120;
var timer = setInterval(function() {
document.getElementById("safeTimerDisplay").innerHTML = seconds;
seconds--;
if (seconds < 0) {
clearInterval(timer);
}
}, 1000);
}
timer();
function endGame() {
if (seconds === 0 && score > 1800) {
console.log(endWindow1)
}
}
#EndWindow1 {
background: url("./endscreen.jpg") no-repeat center center fixed;
background-size: cover;
font-family: Arial, Helvetica, sans-serif;
color: white;
text-align: center;
}
<div id="EndWindow1" style="display:none;"></div>
<h1>Timer: <span id="safeTimerDisplay"></span></h1>
In an attempt to showcase a specific image when the user's score surpasses 1800 and the timer hits zero, I have set up a conditional statement. However, upon reaching zero on the clock, nothing changes and the game continues as normal. It seems like something is interrupting the display of the end screen.