summaryrefslogtreecommitdiff
path: root/src/entities/hello_kitty/bullet_particles.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/hello_kitty/bullet_particles.js')
-rw-r--r--src/entities/hello_kitty/bullet_particles.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/entities/hello_kitty/bullet_particles.js b/src/entities/hello_kitty/bullet_particles.js
new file mode 100644
index 0000000..c4dee60
--- /dev/null
+++ b/src/entities/hello_kitty/bullet_particles.js
@@ -0,0 +1,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()
+ }
+ }
+}