Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with creating Game Over Screen #6

Open
SeanRiggs opened this issue Sep 18, 2023 · 1 comment
Open

Help with creating Game Over Screen #6

SeanRiggs opened this issue Sep 18, 2023 · 1 comment

Comments

@SeanRiggs
Copy link

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

@SeanRiggs
Copy link
Author

if you want to check out what you inspired!

https://github.com/SeanRiggs/HTML5-classic-arcade-game/tree/master/TMNT_Game_Theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant