Update Redditlikespacesuit.HTML

This commit is contained in:
Dangrainage 2023-11-09 10:47:08 +01:00 committed by GitHub
parent 2df3e5cdb4
commit d0c4419ca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,11 +53,11 @@
const invaders = []; const invaders = [];
const invaderWidth = 30; const invaderWidth = 30;
const invaderHeight = 30; const invaderHeight = 30;
const maxInvaders = 2; const maxInvaders = 4;
let failedCount = 0; let failedCount = 0;
let score = 0; let score = 0;
let highestScore = 0; let highestScore = localStorage.getItem("highestScore") || 0;
const leftArrowButton = document.getElementById("left-arrow"); const leftArrowButton = document.getElementById("left-arrow");
const rightArrowButton = document.getElementById("right-arrow"); const rightArrowButton = document.getElementById("right-arrow");
@ -186,6 +186,7 @@
alert("You failed, try again"); alert("You failed, try again");
if (score > highestScore) { if (score > highestScore) {
highestScore = score; highestScore = score;
localStorage.setItem("highestScore", highestScore);
highestScoreDisplay.textContent = highestScore; highestScoreDisplay.textContent = highestScore;
} }
document.location.reload(); document.location.reload();
@ -202,6 +203,7 @@
requestAnimationFrame(updateGameArea); requestAnimationFrame(updateGameArea);
} }
highestScoreDisplay.textContent = highestScore;
updateGameArea(); updateGameArea();
</script> </script>
</body> </body>