Added better bullet spawn mechanics (again)
This commit is contained in:
13
web/game.js
13
web/game.js
@@ -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));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user