I'm making a game with a ball and when it touches the top of the screen you're out. I also have a system that calculates a score and a high score. I want the ball to be brought to its original position when you press OK on the confirm window.
Here's what I have so far:
The score-calculating function: var score = 0; setInterval(function() { if(!paused) score++; diplayScore.innerHTML = "Score:\n" + score; var getHigh = displayHighScore.innerHTML = "High Score:" + highScore; },1000);
When you get out: if (characterTop <= 0) { if(score > highScore) { highScore = score; } if(confirm("Game over. Do you want to play again?") === true) { // Reset Game... } else { // Do Nothing... } }
I've tried resetting the Game with location.reload
, but it resets the high score as well, ruining the point.
Any help would be greatly appreciated.
Thanks so much in advance :)
https://stackoverflow.com/questions/65756945/how-to-move-an-element-back-to-its-original-place-without-location-reload-in-j January 17, 2021 at 11:05AM
没有评论:
发表评论