fixed respawn

This commit is contained in:
Sam
2023-11-30 19:14:02 +01:00
parent 4a2c3dabac
commit c41e3f7dde

View File

@@ -68,13 +68,16 @@ function life() {
time = 0; time = 0;
bounceX = bossPosX; bounceX = bossPosX;
bounceY = bossPosY; bounceY = bossPosY;
initialPlayerPosX = playerPosX;
initialPlayerPosY = playerPosY;
hasMoved = false;
bullets = [];
shot = false;
} }
} }
function movementCheck() { function movementCheck() {
if (playerPosX != initialPlayerPosX && playerPosY != initialPlayerPosY) { if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
hasMoved = true; hasMoved = true;
} }
} }
@@ -201,22 +204,22 @@ function spawnRandomBullet(){
nextAttack = random([1, 2, 3, 4]); nextAttack = random([1, 2, 3, 4]);
text(nextAttack, 30, 50); text(nextAttack, 30, 50);
if (nextAttack == 1) { if (nextAttack == 1) {
shotPosX = 500; shotPosX = 510;
shotPosY = 100; shotPosY = 100;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
} }
if (nextAttack == 2) { if (nextAttack == 2) {
shotPosX = random(0, 1000); shotPosX = random(0, 1000);
shotPosY = 600; shotPosY = 610;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
} }
if (nextAttack == 3) { if (nextAttack == 3) {
shotPosX = 0; shotPosX = -10;
shotPosY = random(0, 600); shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
} }
if (nextAttack == 4) { if (nextAttack == 4) {
shotPosX = 1000; shotPosX = 1010;
shotPosY = random(0, 600); shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));