Help with creating Game Over Screen
SeanRiggs opened this issue · 1 comments
I have forked your repo and customized it to add instructions and other simple things and have themed it. I am trying to add a game-over screen so that I can try to implement a high score screen. I cannot figure out the logic. I can get the app.js to talk to the console but I have tried for hours to add logic to do this .. for example one of the things I tried was:
function checkCollisions() {
// Check if the player's life reaches zero
if (app.ACTORS.player.life <= 0) {
// Display the game over popup
document.getElementById("game-over-popup").style.display = "block";
// Update the final score in the game over popup
document.getElementById("finalScore").textContent = app.ACTORS.player.score;
}
};
app.Player.prototype.update = function() {
if (this.life <= 0) {
// Trigger game over pop-up and send a message when the score is zero
console.log("Sending 'gameOver' message.");
showGameOverPopup(this.score);
// Send a message to the parent window
if (this.score === 0) {
window.parent.postMessage("gameOver", "*");
} else {
console.log("Score is not zero. Message not sent.");
}
}
};
and added a listener to the HTML ... but it wont talk! (I defined the app.Actors.Player as well).
I am stuck for now and was hoping maybe you had insight on this?
I appreciate any insight. Warm Regards
Sean
if you want to check out what you inspired!
https://github.com/SeanRiggs/HTML5-classic-arcade-game/tree/master/TMNT_Game_Theme