summaryrefslogtreecommitdiff
path: root/src/entities/portal.js
blob: 8e3c6c9adba47c48db9e24cf58908a26d53e6052 (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
import { Entity } from "./entity.js"
import { PORTAL } from "../assets.js"
import { Vector } from "../engine/vector.js"
import { Engine } from "../engine.js"
import { SCENE, SCENES } from "../scenes.js"

export class Portal extends Entity {
    constructor() {
        super({
            size: new Vector(150, 150),
            position: new Vector(325, 100),
            sprite: PORTAL[0],
        })

        frames = PORTAL.length
    }

    update() {
        if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
            SCENE.load(SCENES.HELLO_KITTY)
        }
    }

    draw() {
        this.span.src = PORTAL[Math.floor(Engine.frame / 2) % frames]
        super.draw()
    }
}