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

@@ -11,7 +11,6 @@ class bullet {
this.bulletHit = false;
this.directionX = null;
this.directionY = null;
this.hasMoved = hasMoved;
// Set a variable that cant be changed
if ((this.directionX === null) || (this.directionY === null)) {
this.directionX = this.targetx;
@@ -33,7 +32,7 @@ class bullet {
pop();
}
update(targetx, targety) {
update(targetx, targety, hasMoved) {
// keeps the projetile updated so hit collision can be checked
this.targetx = targetx;
this.targety = targety;
@@ -48,7 +47,7 @@ class bullet {
hit = true;
shot = false;
// if the projectile has hit the player and the player has lives left, remove a life
if (this.hasMoved && lives != 0 && this.bulletHit == false) {
if (hasMoved && lives != 0 && this.bulletHit == false) {
this.bulletHit = true;
lives -= 1;
}