Skip to content

feat: level intro camera overview#2

Merged
QilongTang merged 5 commits intomasterfrom
addLevelOverview
May 1, 2026
Merged

feat: level intro camera overview#2
QilongTang merged 5 commits intomasterfrom
addLevelOverview

Conversation

@johnpierson
Copy link
Copy Markdown
Member

Summary

Adds a cinematic camera pan at the start of each level that gives players a quick preview of the goal before gameplay begins.

  • Camera pans from spawn point out to the goal flag (2 s, zoomed to 0.2×), pauses briefly (0.5 s), then returns to the player (1 s) before handing control back
  • Player is frozen (gravity + velocity disabled) during the intro; gravity and startFollow re-enable the moment the intro completes
  • Coin collection is blocked during the intro phase to prevent accidental pickups from the zoomed-out view
  • All timing and zoom values extracted to named constants in GameConfig.ts (INTRO_PAN_OUT_MS, INTRO_PAUSE_MS, INTRO_RETURN_MS, INTRO_ZOOM_OUT) for easy tuning
  • Moved camera.startFollow() out of buildLevelFromGraph and into GameScene so it only activates after the intro finishes

Files changed

File Change
src/config/GameConfig.ts Add 4 intro-sequence constants
src/levels/buildLevelFromGraph.ts Remove premature startFollow call
src/scenes/GameScene.ts Add introPhase state machine + intro update loop

Test plan

  • Load any level — camera should pan to flag, pause, return to player, then gameplay starts normally
  • Player cannot move or collect coins during the intro
  • After intro, camera follows player as before
  • Death/respawn still works correctly (intro replays on respawn)
  • Tweak INTRO_ZOOM_OUT in GameConfig.ts to verify config drives the behavior

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a level-start “cinematic” camera intro that pans from the player spawn to the goal flag and back, freezing gameplay until the sequence completes.

Changes:

  • Introduces an intro-phase state machine in GameScene to pan/zoom the camera and delay player control.
  • Blocks coin pickups during the intro phase to avoid accidental collection.
  • Moves camera follow activation out of buildLevelFromGraph and into GameScene (after the intro), and adds configurable timing/zoom constants to GameConfig.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/config/GameConfig.ts Adds named constants for intro pan/pause/return timings and zoom.
src/levels/buildLevelFromGraph.ts Removes immediate camera.startFollow() so following can be delayed until after the intro.
src/scenes/GameScene.ts Implements intro-phase camera pan/zoom, freezes player, blocks coin collection, and starts camera follow after intro completes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/scenes/GameScene.ts Outdated
Comment thread src/scenes/GameScene.ts
Comment on lines +81 to +91
this.goalX = built.flag.x;
this.goalY = built.flag.y;
this.introPhase = 'pan-out';
this.introElapsed = 0;
this.player.arcadeBody.setAllowGravity(false);
this.player.arcadeBody.setVelocity(0, 0);
const cam = this.cameras.main;
cam.centerOn(this.spawnX, this.spawnY);
cam.pan(this.goalX, this.goalY, INTRO_PAN_OUT_MS, 'Sine.easeInOut');
cam.zoomTo(INTRO_ZOOM_OUT, INTRO_PAN_OUT_MS, 'Sine.easeInOut');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ccc94a4. Added GameScene.introPhase.test.ts with 25 tests covering all three requested areas:

  1. Coin overlap blocked during intro — tests verify the introPhase !== "done" guard rejects coins in all three pre-done phases and allows collection once done.
  2. Camera follow + gravity enabled at intro end — tests verify player.unfreeze() and cameraFollowing are set exactly when introPhase transitions to "done", including boundary ticks.
  3. Death during intro — tests document the original bug (death poll unreachable while intro returns early) and verify the fix: player.dead is now checked before the intro early-return, so handleDeath fires after the 600 ms accumulation even while the camera pan is still running.

Two companion code fixes were also included: Jacobot bug damage is blocked during the intro (new introPhase !== "done" guard on the overlap callback), and arcadeBody.setAllowGravity(true) at intro end was replaced with player.unfreeze() for consistency with freeze() in create().

Comment thread src/scenes/GameScene.ts Outdated
Comment thread src/scenes/GameScene.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
QilongTang and others added 2 commits May 1, 2026 16:24
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Move player.dead poll before intro early-return in update() so deaths
  triggered during the intro (e.g. fire ground) are handled correctly
- Add introPhase !== 'done' guard to Jacobot bug overlap callback so
  Jacobot cannot damage the frozen player during the camera intro
- Use player.unfreeze() instead of direct arcadeBody.setAllowGravity(true)
  for consistency with the freeze() call in create()
- Normalise single-quoted string literals to double quotes in intro code
- Add GameScene.introPhase.test.ts with 25 regression tests covering:
  (1) coin overlap blocked during every intro phase
  (2) intro state machine timing and phase transitions
  (3) player.unfreeze() + camera follow enabled exactly at intro end
  (4) death polled and handleDeath triggered during intro (fix regression)"

Agent-Logs-Url: https://github.com/DynamoDS/DynoDashGame/sessions/b3acf55e-e3c3-48f3-9c0e-4749293c972f

Co-authored-by: QilongTang <3942418+QilongTang@users.noreply.github.com>
@QilongTang QilongTang merged commit 7bd190f into master May 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants