From ff9d9faa2a42e8651f25b4b5d6e79b1f983bb101 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Sat, 8 Nov 2025 03:53:07 -0600 Subject: [PATCH] Step 1: Implement game timer tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added real-time game timer that starts when VR headset tracking is active. **Modified: src/ship.ts** - Added public getter for gameStats to allow Level1 to access it **Modified: src/level1.ts** - Call ship.gameStats.startTimer() in onInitialXRPoseSetObservable - Timer starts when XR pose is set (when VR tracking begins) - Added debug log to confirm timer start The Game Time statistic now tracks actual play time from when the user enters VR, displayed in MM:SS format on the status screen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/level1.ts | 5 +++++ src/ship.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/level1.ts b/src/level1.ts index d2c6640..c699715 100644 --- a/src/level1.ts +++ b/src/level1.ts @@ -43,6 +43,11 @@ export class Level1 implements Level { xr.baseExperience.camera.parent = this._ship.transformNode; const currPose = xr.baseExperience.camera.globalPosition.y; xr.baseExperience.camera.position = new Vector3(0, 0, 0); + + // Start game timer when XR pose is set + this._ship.gameStats.startTimer(); + debugLog('Game timer started'); + const observer = xr.input.onControllerAddedObservable.add((controller) => { debugLog('🎮 onControllerAddedObservable FIRED for:', controller.inputSource.handedness); this._ship.addController(controller); diff --git a/src/ship.ts b/src/ship.ts index 0f21e36..95f0519 100644 --- a/src/ship.ts +++ b/src/ship.ts @@ -59,6 +59,10 @@ export class Ship { return this._scoreboard; } + public get gameStats(): GameStats { + return this._gameStats; + } + public set position(newPosition: Vector3) { const body = this._ship.physicsBody;