diff options
Diffstat (limited to 'src/entities/boshybullet.js')
-rw-r--r-- | src/entities/boshybullet.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/entities/boshybullet.js b/src/entities/boshybullet.js new file mode 100644 index 0000000..ed91ede --- /dev/null +++ b/src/entities/boshybullet.js @@ -0,0 +1,30 @@ +import { BOSHY } from "../assets.js" +import { Vector } from "../engine/vector.js" +import { bullets } from "../main.js" +import { Entity } from "./entity.js" + +export class BoshyBullet extends Entity { + speed = 20 + + constructor(position = new Vector(0,0)) { + super({ + size: new Vector(5, 5), + 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) + } + } + + remove() { + this.span.remove() + } +} |