added collision with boss & first wave can now hit (thx sam)

This commit is contained in:
Mees Roelofsz
2024-01-17 14:50:00 +01:00
parent 5c9317fc20
commit 41d0746fe2
2 changed files with 36 additions and 25 deletions

View File

@@ -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) {