diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
commit | 25adfc618e77db9a5ee3b98ce0dab0be832efed0 (patch) | |
tree | 36ca56758ddd4674ab5a43df4b76bbfcc5a47af1 /src/entities/boshybullet.js | |
parent | a840990bdcabf45fb0d377478ba0ab27222434ae (diff) |
hello kitty base done
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() + } } } |