Skip to content

Lesson 06 — Make risk a timed operation ​

Where this lesson fits: a valid trail can now exist. Add the time pressure that makes remaining exposed a decision rather than a pause button.

Time: 2–3 hours

Prerequisites and outcomes ​

Complete lesson 05. By the end, you can explain warning, ignition, burn progress, movement pause, death threshold, and reset as separate states.

Prepare and run ​

  1. Reuse the tutorial chapter 05 project prepared in lesson 05; do not copy chapter 05 over it again.
  2. Open Source\Systems\FuseSystem.cs and Tests\Systems\FuseSystemTests.cs. Run the test command below from your learner project's solution folder.
  3. Run dotnet run --project Platforms\DesktopVK and follow steps 2–3 of the tutorial's chapter 05 checkpoint: draw inward with the arrow keys, stop, observe the spark, move, stop again, and let it reach the player.
  4. Stage note: chapter 05 cancels the trail and returns to the anchor when the fuse reaches the player. Lives/death arrive in tutorial chapter 07; HUD warning/audio arrive in chapter 08.

Code anchors ​

  • last-perimeter/Source/Systems/FuseSystem.cs
  • last-perimeter/Source/Entities/Trail.cs (GetPointAtDistance)
  • last-perimeter/Tests/Systems/FuseSystemTests.cs
  • last-perimeter/Source/Rendering/HudRenderer.cs
  • last-perimeter/Source/Systems/AudioCuePlayer.cs

Guided operations ​

  1. Follow FuseSystem.Update with no active trail; confirm it resets.
  2. Advance stopped time to the warning threshold, then the trigger threshold. Distinguish the warning state from an active fuse.
  3. Advance burn distance and follow Trail.GetPointAtDistance to locate the fuse on a multi-segment trail.
  4. Before ignition, moving resets the stopped timer. After ignition, moving pauses the existing burn position; stopping again resumes burning.
  5. Let the burn reach the player. Trace the returned signal to trail cancellation in the staged app; revisit shield/death handling in lessons 09 and 13.
  6. Complete or cancel the trail and verify the fuse resets. Revisit the warning signal's HUD and audio consumers in lesson 10.
powershell
dotnet test --filter FullyQualifiedName~FuseSystemTests

Checkpoint ​

Tests distinguish warning from active fuse, movement from stopped time, and reset from pause. In play, the fuse progresses along the actual trail rather than across a straight-line shortcut.

Common mistakes ​

  • Resetting a lit fuse whenever movement resumes instead of pausing its position.
  • Passing button state as proof that the player moved; a blocked movement input is not displacement.
  • Duplicating the fuse timer inside HUD or audio code.

Questions and extension ​

Which cue should fire only once per warning episode? How would you prevent a repeated warning sound every frame?