Bullets dont pass trough you anymore

This commit is contained in:
Sam
2023-11-30 12:17:30 +01:00
parent be8c373561
commit 931824c1c7

View File

@@ -71,6 +71,8 @@ function life() {
time = 0;
bounceX = bossPosX;
bounceY = bossPosY;
hit = false;
}
}
@@ -178,7 +180,12 @@ function draw() {
({ hit, shot } = myBullet.update(playerPosX, playerPosY));
myBullet.draw();
});
//blijf de bullet tekenen zolang hit false is
bullets = bullets.filter(bullet => {
const { hit, shot } = bullet.update(playerPosX, playerPosY);
bullet.draw();
return !hit; // als hit true is dan wordt de bullet verwijderd
});
}
}