From 25adfc618e77db9a5ee3b98ce0dab0be832efed0 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Tue, 24 Dec 2024 17:58:20 +0100 Subject: hello kitty base done --- src/entities/boshybullet.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/entities/boshybullet.js') diff --git a/src/entities/boshybullet.js b/src/entities/boshybullet.js index ed91ede..a87e159 100644 --- a/src/entities/boshybullet.js +++ b/src/entities/boshybullet.js @@ -1,7 +1,8 @@ import { BOSHY } from "../assets.js" import { Vector } from "../engine/vector.js" -import { bullets } from "../main.js" import { Entity } from "./entity.js" +import { enemy } from "../main.js" +import { Engine } from "../engine.js" export class BoshyBullet extends Entity { speed = 20 @@ -12,19 +13,17 @@ export class BoshyBullet extends Entity { position: position.floor(), sprite: BOSHY.BULLET, }) - - bullets.list.push(this) } update() { this.position.y -= this.speed if (this.position.y < 0) { - this.span.remove() - bullets.remove(this) + this.remove() } - } - remove() { - this.span.remove() + if (Engine.collision.collidingWithEnemy(this.position, this.hitbox)) { + enemy.hit() + this.remove() + } } } -- cgit v1.2.3