diff options
Diffstat (limited to 'src/entities/boshybullet.js')
-rw-r--r-- | src/entities/boshybullet.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/entities/boshybullet.js b/src/entities/boshybullet.js index ed91ede..a87e159 100644 --- a/src/entities/boshybullet.js +++ b/src/entities/boshybullet.js @@ -1,7 +1,8 @@ import { BOSHY } from "../assets.js" import { Vector } from "../engine/vector.js" -import { bullets } from "../main.js" import { Entity } from "./entity.js" +import { enemy } from "../main.js" +import { Engine } from "../engine.js" export class BoshyBullet extends Entity { speed = 20 @@ -12,19 +13,17 @@ export class BoshyBullet extends Entity { position: position.floor(), sprite: BOSHY.BULLET, }) - - bullets.list.push(this) } update() { this.position.y -= this.speed if (this.position.y < 0) { - this.span.remove() - bullets.remove(this) + this.remove() } - } - remove() { - this.span.remove() + if (Engine.collision.collidingWithEnemy(this.position, this.hitbox)) { + enemy.hit() + this.remove() + } } } |