From dae779c78b9b57ddbfb01943bd52f9a0c6b19511 Mon Sep 17 00:00:00 2001 From: Thomas Renger Date: Fri, 2 Feb 2024 21:52:41 +0100 Subject: [PATCH] fix: handling the ship --- src/app/services/game-ship.service.ts | 3 +++ src/app/services/game.service.ts | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/services/game-ship.service.ts b/src/app/services/game-ship.service.ts index 86db39e..67585b5 100644 --- a/src/app/services/game-ship.service.ts +++ b/src/app/services/game-ship.service.ts @@ -5,6 +5,7 @@ import { ShipType } from '../models/pixijs/ship-type.enum'; import { ApplicationService } from './application.service'; import { ExplosionService } from './explosion.service'; import { GameShotService } from './game-shot.service'; +import { ObjectService } from './object.service'; import { UpdatableService } from './updatable.service'; @Injectable() @@ -17,6 +18,7 @@ export class GameShipService extends UpdatableService { private readonly application: ApplicationService, private readonly explosionService: ExplosionService, private readonly gameShot: GameShotService, + private readonly object: ObjectService, ) { super(); } @@ -44,6 +46,7 @@ export class GameShipService extends UpdatableService { this.#ship.play(); this.#ship.x = Math.floor(this.application.screen.width / 2); this.#ship.y = this.application.screen.height - 100; + this.object.add(this.#ship); this.application.stage.addChild(this.#ship); } diff --git a/src/app/services/game.service.ts b/src/app/services/game.service.ts index 00421a7..2a29a83 100644 --- a/src/app/services/game.service.ts +++ b/src/app/services/game.service.ts @@ -105,12 +105,10 @@ export class GameService { } this.updatables.forEach(updatable => updatable.update(delta, this.level())); - - + if (this.ship.instance.energy === 0) { void this.storage.setHighscore(this.kills(), this.level()); void this.presentPopup(YouAreDeadPopup); - this.ship.instance.destroy(); this.started.set(false); } });