finished game over ui

This commit is contained in:
Mees Roelofsz
2024-01-06 13:50:10 +01:00
parent bfd4b73fc6
commit 58da9e9bc4

View File

@@ -57,6 +57,7 @@ let chosen = false;
let finalPhase = false;
let nextWave = [];
let iIndex = 0;
let buttonSelect = 0;
let entered = false;
let bulletAmount = 5;
@@ -85,38 +86,25 @@ function gameOver() {
if (lives == 0) {
//game over screen
iIndex = constrain(iIndex, 0, 2);
buttonSelect = constrain(buttonSelect, 0, 2);
isDead = true;
push();
fill(255, 0, 0);
textSize(40);
textAlign(CENTER);
text("Game Over", width / 2, height / 2 - 80);
pop();
push();
fill(255, 255, 255)
textSize(32);
textAlign(CENTER);
text(letters[currentIndex[0]], width / 2 - 30, height / 2);
text(letters[currentIndex[1]], width / 2, height / 2);
text(letters[currentIndex[2]], width / 2 + 30, height / 2);
pop();
if (key == ' ') {
//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;
}
text("Restart", width / 2, height / 2 + 45);
text("Main Menu", width / 2, height / 2 + 90);
pop();
}
}
@@ -174,13 +162,50 @@ async function keyPressed() {
}
if (isDead && keyReleasedFlag && entered) {
if (keyCode == UP_ARROW) {
//
buttonSelect -= 1;
keyReleasedFlag = false;
}
if (keyCode == DOWN_ARROW) {
//
buttonSelect += 1;
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 (entered == true) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2 - 45, height / 2 - 30, 90, 40)
pop()
if (buttonSelect == 0) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
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 {
if (iIndex == 0) {