Step 2: Track asteroids destroyed
Some checks failed
Build / build (push) Failing after 20s

Added real-time tracking of asteroids destroyed by listening to scoreboard score events.

**Modified: src/ship.ts**
- Subscribe to scoreboard.onScoreObservable in initialize()
- Call gameStats.recordAsteroidDestroyed() for each score event
- Each score event represents one asteroid destroyed

The Asteroids Destroyed statistic now updates in real-time on the status screen whenever an asteroid is destroyed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-11-08 03:53:40 -06:00
parent ff9d9faa2a
commit e4fbbce2c7

View File

@ -209,6 +209,12 @@ export class Ship {
// Initialize scoreboard (it will retrieve and setup its own screen mesh) // Initialize scoreboard (it will retrieve and setup its own screen mesh)
this._scoreboard.initialize(); this._scoreboard.initialize();
// Subscribe to score events to track asteroids destroyed
this._scoreboard.onScoreObservable.add((scoreEvent) => {
// Each score event represents an asteroid destroyed
this._gameStats.recordAsteroidDestroyed();
});
// Initialize status screen // Initialize status screen
this._statusScreen = new StatusScreen(DefaultScene.MainScene, this._gameStats); this._statusScreen = new StatusScreen(DefaultScene.MainScene, this._gameStats);
this._statusScreen.initialize(this._camera); this._statusScreen.initialize(this._camera);