finished game over ui
This commit is contained in:
97
web/game.js
97
web/game.js
@@ -57,6 +57,7 @@ let chosen = false;
|
|||||||
let finalPhase = false;
|
let finalPhase = false;
|
||||||
let nextWave = [];
|
let nextWave = [];
|
||||||
let iIndex = 0;
|
let iIndex = 0;
|
||||||
|
let buttonSelect = 0;
|
||||||
let entered = false;
|
let entered = false;
|
||||||
|
|
||||||
let bulletAmount = 5;
|
let bulletAmount = 5;
|
||||||
@@ -85,38 +86,25 @@ function gameOver() {
|
|||||||
if (lives == 0) {
|
if (lives == 0) {
|
||||||
//game over screen
|
//game over screen
|
||||||
iIndex = constrain(iIndex, 0, 2);
|
iIndex = constrain(iIndex, 0, 2);
|
||||||
|
buttonSelect = constrain(buttonSelect, 0, 2);
|
||||||
isDead = true;
|
isDead = true;
|
||||||
push();
|
push();
|
||||||
fill(255, 0, 0);
|
fill(255, 0, 0);
|
||||||
textSize(40);
|
textSize(40);
|
||||||
textAlign(CENTER);
|
textAlign(CENTER);
|
||||||
text("Game Over", width / 2, height / 2 - 80);
|
text("Game Over", width / 2, height / 2 - 80);
|
||||||
pop();
|
|
||||||
push();
|
|
||||||
fill(255, 255, 255)
|
fill(255, 255, 255)
|
||||||
textSize(32);
|
textSize(32);
|
||||||
textAlign(CENTER);
|
textAlign(CENTER);
|
||||||
text(letters[currentIndex[0]], width / 2 - 30, height / 2);
|
text(letters[currentIndex[0]], width / 2 - 30, height / 2);
|
||||||
text(letters[currentIndex[1]], width / 2, height / 2);
|
text(letters[currentIndex[1]], width / 2, height / 2);
|
||||||
text(letters[currentIndex[2]], width / 2 + 30, height / 2);
|
text(letters[currentIndex[2]], width / 2 + 30, height / 2);
|
||||||
pop();
|
|
||||||
|
|
||||||
if (key == ' ') {
|
text("Restart", width / 2, height / 2 + 45);
|
||||||
//reset all the variables so the game can be played again
|
|
||||||
lives = 1;
|
text("Main Menu", width / 2, height / 2 + 90);
|
||||||
time = 0;
|
pop();
|
||||||
bounceX = bossPosX;
|
|
||||||
bounceY = bossPosY;
|
|
||||||
initialPlayerPosX = playerPosX;
|
|
||||||
initialPlayerPosY = playerPosY;
|
|
||||||
hasMoved = false;
|
|
||||||
bullets = [];
|
|
||||||
shot = false;
|
|
||||||
chosen = false;
|
|
||||||
finalPhase = false;
|
|
||||||
isDead = false;
|
|
||||||
entered = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,13 +162,50 @@ async function keyPressed() {
|
|||||||
}
|
}
|
||||||
if (isDead && keyReleasedFlag && entered) {
|
if (isDead && keyReleasedFlag && entered) {
|
||||||
if (keyCode == UP_ARROW) {
|
if (keyCode == UP_ARROW) {
|
||||||
//
|
buttonSelect -= 1;
|
||||||
keyReleasedFlag = false;
|
keyReleasedFlag = false;
|
||||||
}
|
}
|
||||||
if (keyCode == DOWN_ARROW) {
|
if (keyCode == DOWN_ARROW) {
|
||||||
//
|
buttonSelect += 1;
|
||||||
keyReleasedFlag = false;
|
keyReleasedFlag = false;
|
||||||
}
|
}
|
||||||
|
if (buttonSelect == 1) {
|
||||||
|
if (keyCode == ENTER) {
|
||||||
|
//reset all the variables so the game can be played again
|
||||||
|
lives = 1;
|
||||||
|
time = 0;
|
||||||
|
bounceX = bossPosX;
|
||||||
|
bounceY = bossPosY;
|
||||||
|
initialPlayerPosX = playerPosX;
|
||||||
|
initialPlayerPosY = playerPosY;
|
||||||
|
hasMoved = false;
|
||||||
|
bullets = [];
|
||||||
|
shot = false;
|
||||||
|
chosen = false;
|
||||||
|
finalPhase = false;
|
||||||
|
isDead = false;
|
||||||
|
entered = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buttonSelect == 2) {
|
||||||
|
if (keyCode == ENTER) {
|
||||||
|
homescreenOn = true;
|
||||||
|
|
||||||
|
lives = 1;
|
||||||
|
time = 0;
|
||||||
|
bounceX = bossPosX;
|
||||||
|
bounceY = bossPosY;
|
||||||
|
initialPlayerPosX = playerPosX;
|
||||||
|
initialPlayerPosY = playerPosY;
|
||||||
|
hasMoved = false;
|
||||||
|
bullets = [];
|
||||||
|
shot = false;
|
||||||
|
chosen = false;
|
||||||
|
finalPhase = false;
|
||||||
|
isDead = false;
|
||||||
|
entered = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,12 +257,30 @@ function draw() {
|
|||||||
}
|
}
|
||||||
if (isDead == true) {
|
if (isDead == true) {
|
||||||
if (entered == true) {
|
if (entered == true) {
|
||||||
push()
|
if (buttonSelect == 0) {
|
||||||
stroke(205, 205, 205)
|
push()
|
||||||
strokeWeight(2)
|
stroke(205, 205, 205)
|
||||||
fill(0, 0, 0, 0)
|
strokeWeight(2)
|
||||||
rect(width / 2 - 45, height / 2 - 30, 90, 40)
|
fill(0, 0, 0, 0)
|
||||||
pop()
|
rect(width / 2 - 45, height / 2 - 30, 90, 40)
|
||||||
|
pop()
|
||||||
|
}
|
||||||
|
if (buttonSelect == 1) {
|
||||||
|
push()
|
||||||
|
stroke(205, 205, 205)
|
||||||
|
strokeWeight(2)
|
||||||
|
fill(0, 0, 0, 0)
|
||||||
|
rect(width / 2 - 55, height / 2 + 15, 110, 40)
|
||||||
|
pop()
|
||||||
|
}
|
||||||
|
if (buttonSelect == 2) {
|
||||||
|
push()
|
||||||
|
stroke(205, 205, 205)
|
||||||
|
strokeWeight(2)
|
||||||
|
fill(0, 0, 0, 0)
|
||||||
|
rect(width / 2 - 80, height / 2 + 60, 160, 40)
|
||||||
|
pop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (iIndex == 0) {
|
if (iIndex == 0) {
|
||||||
|
Reference in New Issue
Block a user