Skip to content

Commit

Permalink
Make keyPress interact with status variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonzero committed Sep 13, 2013
1 parent bca2419 commit e2f8d2c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ var game = {
//logic
update:function() {
switch(this.status) {
case "play"
case "play":
theKey.update();
scoreboard.update();
break;
}
},

//drawing to screen
Expand Down Expand Up @@ -78,35 +80,35 @@ var keyBoardInput = {

if(e.keyCode === 8) {
//restarts game if you press backspace while in the finish screen
if (finish.enabled) {
if (game.status === "finish") {
finish.restart();
}
//restarts game if you press backspace while the game is paused
else if (pause.enabled && !menu.enabled) {
else if (game.status === "pause") {
pause.restart();
}
}
else if(e.keyCode == 27) {
//exits to main menu if you press escape while the game is paused
if (pause.enabled) {
if (game.status === "pause") {
pause.exit();
}
}
//toggles pause when space key is pressed
else if(e.keyCode === 32) {
if (finish.enabled) {
if (game.status === "finish") {
finish.skip();
}
else if(menu.enabled) {
else if(game.status === "menu") {
menu.start();
}
else {
else if (game.status === "pause" || "play") {
pause.toggle();
}
}
//passes in the letter pressed
else if(e.keyCode >= 65 && e.keyCode < 91) {
if (!pause.enabled) {
if (game.status === "play") {
theKey.keyPressed(e.keyCode - 65);
}
}
Expand Down

0 comments on commit e2f8d2c

Please sign in to comment.