summaryrefslogtreecommitdiff
path: root/src/entities/bigdump.js
blob: 90b4a57d5f647cd5f24b0389cd87ef199ff753c7 (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
30
31
32
33
34
35
36
37
38
39
40
import { ANTICHEESE } from "../assets.js"
import { Vector } from "../engine/vector.js"
import { Engine } from "../engine.js"
import { Entity } from "./entity.js"
import { boshy } from "../main.js"

export class BigDump extends Entity {
    constructor(bottom = false) {
        let position = bottom ? 
            new Vector(0, boshy.position.y) :
            new Vector(boshy.position.x, 0)

        super({
            size: new Vector(200, 10),
            position: position,
            sprite: ANTICHEESE,
            degrees: bottom ? 270 : 0,
        })

        this.bottom = bottom
    }

    speed = 10
    maxSize = 200

    update() {
        if (this.size.y < this.maxSize) this.size.y += this.speed * 0.75
        if (this.bottom) this.position.x += this.speed
        else this.position.y += this.speed

        console.log("dump", this.position)

        if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
            boshy.die()
        }
        if (Engine.screen.isOffLimits(this.position, this.size)) {
            this.remove()
        }
    }
}