summaryrefslogtreecommitdiff
path: root/src/entities/hello_kitty/bullet_particles.js
blob: c4dee60e0dd86b0e022e1bd6b0bf79ee56d75f55 (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 { HELLO_KITTY } from "../../assets.js"
import { Vector } from "../../engine/vector.js"
import { Engine } from "../../engine.js"
import { Entity } from "../entity.js"

export class BulletParticle extends Entity {
    constructor(position) {
        super({
            size: new Vector(20, 20),
            position: position,
            sprite: HELLO_KITTY.BULLET,
        })
        this.rotation = Engine.random(0, 360)
        this.rotationSpeed = Engine.random(-10, 10)
        this.velocity = new Vector(
            Engine.random(-2, 2),
            Engine.random(-2, 2),
        )
    }

    update() {
        this.position.add(this.velocity)
        this.rotation += this.rotationSpeed
        this.size.x = this.size.y -= 1
        if (this.size.x <= 0) {
            this.remove()
        }
    }
}