summaryrefslogtreecommitdiff
path: root/src/entities/boshybullet.js
blob: a87e159fdbcc79542e90a0fca07bb296b9da5263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { BOSHY } from "../assets.js"
import { Vector } from "../engine/vector.js"
import { Entity } from "./entity.js"
import { enemy } from "../main.js"
import { Engine } from "../engine.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,
        })
    }

    update() {
        this.position.y -= this.speed
        if (this.position.y < 0) {
            this.remove()
        }

        if (Engine.collision.collidingWithEnemy(this.position, this.hitbox)) {
            enemy.hit()
            this.remove()
        }
    }
}