Appearance
Lesson 12 — Create levels from data
Where this lesson fits: the core loop has been tested. Replace one fixed setup with a level definition that supplies a coherent set of parameters to the runtime.
Time: 2–3 hours
Prerequisites and outcomes
Complete the core pass. By the end, you can explain the level-definition boundary and distinguish per-level reset from run state.
Prepare and run
- From your learner project's solution folder, follow tutorial chapter 10 steps 1–9.
- Open
Source\Systems\LevelProgressionSystem.csand the staged app'sSetupLevel. Run the focused command below. - Run
dotnet run --project Platforms\DesktopVKand perform the level-transition observations in the tutorial's checkpoint.
Code anchors
last-perimeter/Source/Data/LevelDefinition.cslast-perimeter/Source/Systems/LevelProgressionSystem.cslast-perimeter/Source/Game/LastPerimeterApp.cs(SetupLevel,CreateEnemies)last-perimeter/Tests/Systems/LevelProgressionSystemTests.cs
Guided operations
- Follow
CreateLevelfor a level number and difficulty preset. Record the values it returns: goal percentage, speed multiplier, enemy roster, and arena variation. - Trace
Initializeand the level-complete update intoSetupLevel. Identify which objects are rebuilt and which session values survive.StartRunis introduced in tutorial chapter 12. - Follow active configuration derivation from the base config. Explain why each level should start from base values instead of multiplying the previous level's result; run modifiers arrive in lesson 15.
- Trace creation of arena, wall path, enemies, and initial player position.
- Run the progression tests and compare two level definitions; verify only intended parameters change.
powershell
dotnet test --filter FullyQualifiedName~LevelProgressionSystemTestsCheckpoint
Level generation is reproducible from its inputs, setup resets level-scoped state, and the player's score and remaining lives carry forward. Profile persistence arrives in lesson 14.
Common mistakes
- Incrementally mutating the previous level's configuration and compounding difficulty.
- Forgetting to clear temporary powerups, fuse state, or pending upgrade choices.
- Putting permanent statistics on the per-level arena.
Questions and extension
How should a new arena shape affect initial player placement and enemy placement? Write the invariants before implementing a new shape.

