Removed off screen bullets that was causing lag

This commit is contained in:
Sam
2023-11-30 22:38:17 +01:00
parent e98ce2415d
commit 78c95b29f7
2 changed files with 9 additions and 2 deletions

View File

@@ -178,8 +178,13 @@ function draw() {
bullets.forEach(myBullet => {
//zolang mybullet bestaat blijft hij drawen en updaten
({ hit, shot } = myBullet.update(playerPosX, playerPosY));
({ hit, shot, isOffScreen } = myBullet.update(playerPosX, playerPosY));
myBullet.draw();
if (isOffScreen == true) {
myBullet.hit = true;
shot = false;
}
});
//blijf de bullet tekenen zolang hit false is
bullets = bullets.filter(bullet => !bullet.hit);