diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-23 18:32:29 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-23 18:32:29 +0100 |
commit | a840990bdcabf45fb0d377478ba0ab27222434ae (patch) | |
tree | 030a6c3a6befce284733f5643d3972e3a1504bb2 /src/entities/boshybullet.js |
initial commit
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() + } +} |