added collision with boss & first wave can now hit (thx sam)
This commit is contained in:
56
web/game.js
56
web/game.js
@@ -625,27 +625,31 @@ function spawnRandomBullet() {
|
||||
bulletAmount = 5;
|
||||
}
|
||||
}
|
||||
// function bouncing() {
|
||||
// // Update position
|
||||
// bossPosX += bossVelX;
|
||||
// bossPosY += bossVelY;
|
||||
// // Check for bounce
|
||||
// if (bossPosX > width - 25) {
|
||||
// bossVelX = random([-4,-5,-6])
|
||||
// }
|
||||
// if (bossPosX < 25) {
|
||||
// bossVelX = random([4,5,6])
|
||||
// }
|
||||
// if (bossPosY > height - 25) {
|
||||
// bossVelY = random([-4,-5,-6])
|
||||
// }
|
||||
// if (bossPosY < 25) {
|
||||
// bossVelY = random([4,5,6])
|
||||
// }
|
||||
function bouncing() {
|
||||
// Update position
|
||||
bossPosX += bossVelX;
|
||||
bossPosY += bossVelY;
|
||||
// Check for bounce
|
||||
if (bossPosX > width - 25) {
|
||||
bossVelX = random([-4,-5,-6]);
|
||||
}
|
||||
if (bossPosX < 25) {
|
||||
bossVelX = random([4,5,6]);
|
||||
}
|
||||
if (bossPosY > height - 25) {
|
||||
bossVelY = random([-4,-5,-6]);
|
||||
}
|
||||
if (bossPosY < 25) {
|
||||
bossVelY = random([4,5,6]);
|
||||
}
|
||||
|
||||
// // Draw the boss
|
||||
// circle(bossPosX, bossPosY, 50);
|
||||
// }
|
||||
// Draw the boss
|
||||
circle(bossPosX, bossPosY, 50);
|
||||
|
||||
if (dist(bossPosX, bossPosY, playerPosX, playerPosY) <= 25 + radius) {
|
||||
lives -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
function game() {
|
||||
if (!(lives == 0)) {
|
||||
@@ -656,7 +660,15 @@ function game() {
|
||||
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
||||
pop();
|
||||
movementCheck();
|
||||
//bouncing();
|
||||
if (phases[2] == false || phase[3] == false) {
|
||||
bouncing();
|
||||
} else if (phases[2] = true) {
|
||||
bossPosX = x2;
|
||||
bossPosY = y2;
|
||||
} else{
|
||||
bossPosX = width / 2;
|
||||
bossPosY = height / 6;
|
||||
}
|
||||
|
||||
push();
|
||||
fill(255, 165, 0)
|
||||
@@ -714,7 +726,7 @@ function game() {
|
||||
if (!pausescreenOn) {
|
||||
bullets.forEach(myBullet => {
|
||||
//zolang mybullet bestaat blijft hij drawen en updaten
|
||||
({ hit, shot, isOffScreen, originalPos } = myBullet.update(playerPosX, playerPosY));
|
||||
({ hit, shot, isOffScreen, originalPos } = myBullet.update(playerPosX, playerPosY, hasMoved));
|
||||
myBullet.draw();
|
||||
|
||||
if (isOffScreen == true) {
|
||||
|
Reference in New Issue
Block a user