fixed respawn
This commit is contained in:
17
web/game.js
17
web/game.js
@@ -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));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user