Appearance
Lesson 13 — Add collectible effects
Where this lesson fits: levels now have configurable threats. Add pickups as a lifecycle—spawn, remain available, collect, apply, expire, and reset—not as a rendering-only object.
Time: 2–3 hours
Prerequisites and outcomes
Complete lesson 12. By the end, you can follow one powerup end to end and identify which effects belong to a level, a run, or an immediate player change.
Prepare and run
- From your learner project's solution folder, follow tutorial chapter 11 steps 1–5.
- Open
Source\Systems\PowerupSystem.csand findApplyPowerupinSource\Game\LastPerimeterApp.cs. Run the focused command below. - Run
dotnet run --project Platforms\DesktopVKand use the tutorial's checkpoint to observe spawning, collection, and effects. - Stage note: persisted collection statistics arrive with
ProfileTrackerin tutorial chapter 12. Inspect the final app separately or return to statistics in lesson 16.
Code anchors
last-perimeter/Source/Systems/PowerupSystem.cslast-perimeter/Source/Entities/Powerup.cslast-perimeter/Source/Data/Enums.cslast-perimeter/Source/Game/LastPerimeterApp.cs(UpdateGameplay,ApplyPowerup)last-perimeter/Tests/Systems/PowerupSystemTests.cs
Guided operations
- Trace the spawn timer and the maximum active count. Inspect why spawning uses the current wall path.
- Follow lifetime updates and collection overlap. Confirm collected or expired powerups leave the active list.
- Trace each effect into its owning value: shield charges, freeze duration, extra life, fuse reset, or double-points duration.
- Follow the collection event into audio, HUD, and level reset. Separate the effect's behavior from its visual cue; follow profile statistics after lesson 14.
- Run the focused powerup tests and verify one effect in play.
powershell
dotnet test --filter FullyQualifiedName~PowerupSystemTestsCheckpoint
A pickup cannot be collected twice, effects expire or are consumed according to their rules, and a new level clears only the effects that are level-scoped.
Common mistakes
- Spawning on a stale path after a capture.
- Removing an item visually but leaving it collectible in the model.
- Giving every effect the same lifetime/reset behavior without checking its owner.
Questions and extension
How could a deterministic test validate a pickup's location without depending on random output? Inject or control the random source rather than asserting against an arbitrary seed.

