blob: 1f68ba666c9482a65c7a719e4a5f71fe1f999385 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import { HELLO_KITTY } from "../../assets.js"
import { Vector } from "../../engine/vector.js"
import { Entity } from "../entity.js"
import { BulletParticle } from "./bullet_particles.js"
export class Bullet extends Entity {
constructor({
position,
speed,
spinning = false,
degrees = 0,
gravity = 0,
}) {
super({
size: new Vector(30, 30),
hitbox: new Vector(20, 20),
position: position,
sprite: HELLO_KITTY.BULLET,
degrees: degrees
})
this.spinning = spinning
this.velocity = Vector.fromDeg(degrees)
this.velocity.multiply(speed)
// this.velocity.floor()
this.gravity = gravity
if (speed > 6) this.emittingParticles = true
}
particleReloadTime = 10
particleTimeWait = this.particleReloadTime
spinSpeed = 10
update() {
this.velocity.y += this.gravity
this.position.add(this.velocity)
if (this.emittingParticles) {
if (!this.particleTimeWait) {
this.particleTimeWait = this.particleReloadTime
new BulletParticle(this.position.clone())
}
this.particleTimeWait--
}
if (this.spinning) this.rotation += this.spinSpeed
this.updateAsHazard()
this.checkBounds()
}
}
|