Added better bullet spawn mechanics (again)

This commit is contained in:
sam
2023-12-01 11:44:59 +01:00
parent 9e5b9484c4
commit d6a9b21cf1

View File

@@ -71,13 +71,18 @@ 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;
} }
} }
@@ -215,16 +220,16 @@ function spawnRandomBullet() {
} }
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, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
} }
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, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
} }
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, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));