added gameover screen to menu.js and stopped drawing player and boss when paused
This commit is contained in:
62
web/game.js
62
web/game.js
@@ -103,35 +103,12 @@ function reset() {
|
||||
buttonSelectPause = 0;
|
||||
submitted = false;
|
||||
escaped = false;
|
||||
bossPosX = width / 2;
|
||||
bossPosY = height / 6;
|
||||
bossVelX = 5;
|
||||
bossVelY = 5;
|
||||
}
|
||||
function gameOver() {
|
||||
if (lives == 0) {
|
||||
//game over screen
|
||||
iIndex = constrain(iIndex, 0, 2);
|
||||
isDead = true;
|
||||
push();
|
||||
fill(255, 0, 0);
|
||||
textSize(40);
|
||||
textAlign(CENTER);
|
||||
text("Game Over", width / 2, height / 2 - height / 6);
|
||||
|
||||
fill(255, 255, 255)
|
||||
textSize(18);
|
||||
textAlign(CENTER);
|
||||
text("Score: " + int(time), width / 2, height / 2 - height / 8);
|
||||
|
||||
textSize(32);
|
||||
textAlign(CENTER, 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);
|
||||
|
||||
text("Restart", width / 2, height / 2 + height / 12);
|
||||
|
||||
text("Main Menu", width / 2, height / 2 + height / 6);
|
||||
pop();
|
||||
}
|
||||
}
|
||||
function movementCheck() {
|
||||
//check if the player has moved
|
||||
if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
|
||||
@@ -646,7 +623,7 @@ function bouncing() {
|
||||
// Draw the boss
|
||||
circle(bossPosX, bossPosY, 50);
|
||||
|
||||
if (dist(bossPosX, bossPosY, playerPosX, playerPosY) <= 25 + radius) {
|
||||
if ((dist(bossPosX, bossPosY, playerPosX, playerPosY) <= 25 + radius) && hasMoved) {
|
||||
lives -= 1;
|
||||
}
|
||||
}
|
||||
@@ -655,23 +632,24 @@ function game() {
|
||||
if (!(lives == 0)) {
|
||||
// draw player
|
||||
phase();
|
||||
push();
|
||||
fill(0, 255, 255)
|
||||
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
||||
pop();
|
||||
movementCheck();
|
||||
|
||||
|
||||
push();
|
||||
fill(0, 255, 0);
|
||||
if (phases[2] == false || phase[3] == false) {
|
||||
bouncing();
|
||||
} else if (phases[2] = true) {
|
||||
bossPosX = x2;
|
||||
bossPosY = y2;
|
||||
} else {
|
||||
bossPosX = width / 2;
|
||||
bossPosY = height / 6;
|
||||
if (!pausescreenOn) {
|
||||
push();
|
||||
fill(0, 255, 255);
|
||||
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
||||
pop();
|
||||
if (phases[2] == false || phase[3] == false) {
|
||||
bouncing();
|
||||
} else if (phases[2] = true) {
|
||||
bossPosX = x2;
|
||||
bossPosY = y2;
|
||||
} else {
|
||||
bossPosX = width / 2;
|
||||
bossPosY = height / 6;
|
||||
}
|
||||
}
|
||||
pop();
|
||||
if (hasMoved == true) {
|
||||
@@ -726,7 +704,7 @@ function game() {
|
||||
if (!pausescreenOn) {
|
||||
bullets.forEach(myBullet => {
|
||||
//zolang mybullet bestaat blijft hij drawen en updaten
|
||||
({ hit, shot, isOffScreen, originalPos } = myBullet.update(playerPosX, playerPosY, hasMoved));
|
||||
({ hit, shot, isOffScreen, originalPos } = myBullet.update(playerPosX, playerPosY, hasMoved, radius));
|
||||
myBullet.draw();
|
||||
|
||||
if (isOffScreen == true) {
|
||||
|
@@ -81,7 +81,6 @@ function scoremenu() {
|
||||
clearDataOnce = true;
|
||||
}
|
||||
|
||||
|
||||
if (scorescreenOn && keyReleasedFlag) {
|
||||
nameSubmit();
|
||||
}
|
||||
@@ -101,7 +100,7 @@ function scoremenu() {
|
||||
else {
|
||||
nameDraw(3);
|
||||
}
|
||||
|
||||
|
||||
push()
|
||||
fill(255, 255, 255)
|
||||
textSize(25)
|
||||
@@ -134,4 +133,33 @@ function scoremenu() {
|
||||
text("Your scores", width / 4, height / 6)
|
||||
text("Your achievements", width / 4 * 3, height / 6)
|
||||
pop()
|
||||
}
|
||||
|
||||
function gameOver() {
|
||||
if (lives <= 0) {
|
||||
//game over screen
|
||||
iIndex = constrain(iIndex, 0, 2);
|
||||
isDead = true;
|
||||
push();
|
||||
fill(255, 0, 0);
|
||||
textSize(60);
|
||||
textAlign(CENTER, CENTER);
|
||||
text("Game Over", width / 2, height / 2 - height / 5);
|
||||
|
||||
fill(255, 255, 255)
|
||||
textSize(18);
|
||||
text("Score: " + int(time), width / 2, height / 2 - height / 8);
|
||||
|
||||
textSize(32);
|
||||
textAlign(CENTER, 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);
|
||||
|
||||
|
||||
text("Restart", width / 2, height / 2 + height / 12);
|
||||
|
||||
text("Main Menu", width / 2, height / 2 + height / 6);
|
||||
pop();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user