Skip to content

Lesson 10 — Close the feedback loop ​

Where this lesson fits: game rules now create meaningful outcomes. Make those outcomes legible through score, color, HUD, and sound without moving the rules into presentation.

Time: 3–4 hours

Prerequisites and outcomes ​

Complete lessons 06–09. By the end, you can trace a gameplay event to its model update and presentation cue, and explain the claimed-area renderer's cache boundary.

Prepare and run ​

  1. From your learner project's solution folder, follow tutorial chapter 08 steps 1–9.
  2. Open Source\Systems\ScoringSystem.cs, Source\Rendering\HudRenderer.cs, and Source\Systems\AudioCuePlayer.cs. Run the focused command below.
  3. Run dotnet run --project Platforms\DesktopVK and perform the slow-draw, score, and fuse-warning steps in the tutorial's checkpoint. To observe level completion, keep capturing until the displayed percentage reaches the HUD target and note the status message.
  4. Stage note: powerup effects and their HUD indicators arrive in tutorial chapter 11 / LP3 lesson 13. Revisit those indicators then.

Code anchors ​

  • last-perimeter/Source/Systems/ScoringSystem.cs
  • last-perimeter/Source/Rendering/HudRenderer.cs
  • ClaimedAreaRenderer.cs, BitmapTextRenderer.cs, PrimitiveDrawing.cs
  • last-perimeter/Source/Systems/AudioCuePlayer.cs
  • last-perimeter/Tests/Systems/ScoringSystemTests.cs

Guided operations ​

  1. Trace claim tile count and the trail's slow-draw flag into ScoreClaim. Check the current per-percent overshoot and level-bonus rules.
  2. Follow session values into the HUD. Identify indicators for claimed percentage, target, lives, score, fuse, and safety. Check temporary effects after lesson 13.
  3. Follow a claim into ArenaSystem and then the cached ClaimedAreaRenderer. Explain why the renderer is marked dirty after committed grid changes.
  4. Find how procedural drawing uses a one-pixel texture and how audio cues are synthesized. No content-pipeline import is required.
  5. Run scoring tests and play through warning, claim, and level completion. Compare screen feedback with model state. Test a powerup effect in lesson 13.
powershell
dotnet test --filter FullyQualifiedName~ScoringSystemTests

Checkpoint ​

Displayed state matches the model, slow claims are identified and scored from the trail's stored state, and render/audio code reports events rather than deciding gameplay outcomes.

Common mistakes ​

  • Sampling the slow-draw input at claim completion instead of reading the completed trail.
  • Rebuilding the render target during an open sprite batch.
  • Letting a HUD string become the only record of a gameplay state.

Questions and extension ​

What feedback channel is available to a player who cannot rely on color or sound? Consider the shipped accessibility settings before proposing a new cue.