Skip to content

Commit

Permalink
update to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jul 28, 2023
1 parent dfb5f3f commit 358f290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "devdays-arcade-games",
"productName": "Devdays-arcade-games",
"version": "2.0.0",
"version": "3.0.0",
"description": "Custom Pacman and Space Invaders game",
"main": "src/main.js",
"scripts": {
Expand Down
23 changes: 10 additions & 13 deletions src/ui/space/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CANVAS_ID = "game-canvas";
document.addEventListener("keydown", goBack);

function goBack(event) {
if (event.key === "Enter") {
if (event.code === KEY_CODE_ENTER) {
window.history.back();
}
}
Expand Down Expand Up @@ -2416,8 +2416,8 @@ SpaceInvaders.IngameState = function (game) {
* for a first time. This makes it an ideal place to put all listener logic.
*/
this.enter = function () {
document.addEventListener("keyup", this.keyUp);
document.removeEventListener("keydown", goBack);
document.addEventListener("keyup", this.keyUp);
document.addEventListener("keydown", this.keyDown);
};

Expand All @@ -2430,6 +2430,7 @@ SpaceInvaders.IngameState = function (game) {
this.exit = function () {
document.removeEventListener("keyup", this.keyUp);
document.removeEventListener("keydown", this.keyDown);
document.addEventListener("keydown", goBack);
};

/** *************************************************************************
Expand Down Expand Up @@ -2465,18 +2466,14 @@ SpaceInvaders.IngameState = function (game) {
}
break;
case game.KEY_ENTER: {
if (gameOverText.isVisible()) {
// reset game context before returning to welcome scene.
game.getPlayer1Context().reset();
game.getPlayer2Context().reset();
// reset game context before returning to welcome scene.
game.getPlayer1Context().reset();
game.getPlayer2Context().reset();

// return back to the welcome scene.
var scene = game.getScene();
var state = new SpaceInvaders.WelcomeState(game);
scene.setState(state);
} else {
window.history.back();
}
// return back to the welcome scene.
var scene = game.getScene();
var state = new SpaceInvaders.WelcomeState(game);
scene.setState(state);
break;
}
}
Expand Down

0 comments on commit 358f290

Please sign in to comment.