added restart button in lives === 0 if

This commit is contained in:
Mees Roelofsz
2023-12-03 16:34:15 +01:00
parent ddf26c61ab
commit 08e2d5347a

View File

@@ -64,7 +64,6 @@ function life() {
textSize(40); textSize(40);
textAlign(CENTER); textAlign(CENTER);
text("Game Over", 500, 300); text("Game Over", 500, 300);
}
if (key == ' ') { if (key == ' ') {
lives = 1; lives = 1;
time = 0; time = 0;
@@ -75,11 +74,11 @@ function life() {
hasMoved = false; hasMoved = false;
bullets = []; bullets = [];
shot = false; shot = false;
} }
} }
}
function movementCheck() { function movementCheck() {
if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) { if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
hasMoved = true; hasMoved = true;
@@ -206,7 +205,7 @@ function randomAttackPattern() {
function spawnRandomBullet() { function spawnRandomBullet() {
let patern = random([1,2,3,4]); let patern = random([2]);
if (patern == 1) { if (patern == 1) {
nextAttack = random([1, 2, 3, 4]); nextAttack = random([1, 2, 3, 4]);
text(nextAttack, 30, 50); text(nextAttack, 30, 50);