From 474a7253b6b67e2ed33936f6b633587d5d304b66 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Thu, 26 Dec 2024 14:24:53 +0100 Subject: hello kitty stage 1 and 2 done --- src/entities/hello_kitty/bullet_particles.js | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/entities/hello_kitty/bullet_particles.js (limited to 'src/entities/hello_kitty/bullet_particles.js') 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() + } + } +} -- cgit v1.2.3