Appearance
Building a territory-capture arcade game
This tutorial is a publishable chapter guide for building a territory-capture arcade game in MonoGame. Each chapter can stand alone. The full set is a complete course, from an empty folder to a finished game. The finished game has levels, enemies, powerups, menus, a roguelite run structure, a daily challenge, and accessibility options.
The game is called Last Perimeter. Its theme is inspired by the 1981 arcade game Qix, and chapter 00 covers that history. Last Perimeter is an independent game and is not affiliated with or endorsed by the owner of Qix.

Every frame above is a real screenshot of a chapter build. Chapter 00 explains them one by one.
Audience and prerequisites
The course targets the intermediate C# developer: comfortable with classes, generics, and LINQ, but with no MonoGame or game-development experience required. Everything game-specific is taught from scratch. That covers the loop, rendering, input, and the split between simulation and rendering. The content pipeline is explained, but you will not need it. Chapter 01 starts with what the MonoGame template gives you and how this project changes it.
You will need:
- the .NET 10 SDK (the projects target
net10.0, and there is noglobal.json), - any OS that runs .NET and MonoGame DesktopVK (Windows, Linux or macOS), with WindowsDX12 as an optional second platform on Windows,
- a code editor (no IDE-specific tooling is assumed),
- a copy of the course repository, because from chapter 02 you copy each chapter's files from it.
Get the course repository before you start. Open a terminal in the folder where you keep your projects and run:
bash
git clone https://github.com/SimonDarksideJ/LastPerimeter-GameLearningPlan.gitIf you do not use Git, open that address in a browser, choose Code, then Download ZIP, and extract the ZIP. Note the full path of the folder you end up with. The chapters write it as <course-repo>, and you replace that with your own path whenever a command uses it.
How this tutorial is organised
The documentation follows the layout of MonoGame's Building 2D Games tutorial:
| Folder | What it holds |
|---|---|
DOCUMENTATION/LastPerimeter-Tutorial/ | this page, and one folder per chapter |
DOCUMENTATION/LastPerimeter-Tutorial/NN_chapter_name/index.md | the chapter text |
DOCUMENTATION/LastPerimeter-Tutorial/NN_chapter_name/images/ | the chapter's diagrams and screenshots |
DOCUMENTATION/LastPerimeter-Tutorial/NN_chapter_name/snippets/ | every C#, XML and JSON listing in the chapter, one file each |
DOCUMENTATION/LastPerimeter-Source/NN-Chapter-Name/ | the buildable project at the end of that chapter |
last-perimeter/ | the finished game, identical to the chapter 15 project |
DOCUMENTATION/Plan/ | the design, review and QA documents behind the course |
Each listing is shown inline in the chapter so it reads on GitHub, and also kept as a file in snippets/. A comment above the listing names its file. The file is the one to edit. After changing it, run python3 scripts/sync_snippets.py to copy it into the chapter. CI fails if a listing and its file differ.
How each chapter is structured
Every implementation chapter follows the same shape, so you always know where you are:
| Section | What it gives you |
|---|---|
| Navigation | links to the previous chapter, this page and the next chapter, at the top and the bottom |
| Where this chapter fits and Time | one line on what exists before and after, a screenshot of the chapter's end state, and how long to allow |
| Prerequisites and Learning objectives | what to have done, and what "done" means for this chapter |
| Code anchors | the real files in the repository the chapter covers |
| Concept sections | the ideas, each under its own heading, with a diagram where a picture explains more than prose |
| Build it step by step | numbered steps, each naming its file, with the actual code and the changes to the game class |
| Chapter snapshot | the buildable folder that matches the chapter, and the exact number of tests that should pass |
| Checkpoint | what to run and what you should see, with screenshots |
| What you should have now | a short recap of what exists at the end of the chapter |
| Common mistakes | the traps, and what you would see if you fell into one |
| Questions to think about and Extensions | questions to test your understanding, then exercises for when you want more |
Not every chapter needs every closing section, but the sections a chapter has always come in this order.
IMPORTANT
Chapter 01 is type-along: you create every file by hand, so you see how a MonoGame project fits together. From chapter 02 the course is copy-along. Step 1 of each chapter gives you the command that copies that chapter's files from its snapshot folder into your project. The steps after it walk through what changed and why. That code is already in the files you copied, so you read those steps and type nothing unless a step tells you to. The listings show the parts worth studying, not every line.
Conventions used throughout:
- paths are written with forward slashes from the project folder (
Source/Systems/ArenaSystem.cs). In this repository the finished game's project folder islast-perimeter/, and each chapter snapshot is a project folder of its own, - every code listing is taken from the repository or the chapter's staged app; when a listing is abbreviated, a comment says what was left out,
- diagrams are generated from the real numbers in the code (see the tooling section), and screenshots are captured from the chapter builds by a script; the few frames that needed a scratch modification (a lowered claim goal to reach the upgrade draft) say so in their caption,
- Escape closes the window in chapters 01-11 and opens the pause menu from chapter 12 on.
Course intent
By the end of the course you can:
- turn an arcade idea into clean runtime systems,
- separate simulation, rendering, and temporary geometry,
- reason about node paths, rasterisation, and flood fill,
- test difficult game logic instead of trusting visuals alone,
- ship a game that feels good as well as being technically correct.
Chapter map
| Chapter | Title | Focus | Tests passing | Source |
|---|---|---|---|---|
| 00 | Overview, Game Idea, and History | Why a territory-capture game is good to learn from; the three kinds of space | (paper only) | none |
| 01 | New Project and Basic Rendering | MonoGame from zero: the template, the Game lifecycle, one pixel that draws everything | 3 | 01-New-Project-And-Basic-Rendering |
| 02 | Arena Model and Game State Foundations | Screen layout, the tile grid, world-to-grid quantisation, GameSession | 6 | 02-Arena-Model-And-Game-State-Foundations |
| 03 | Input, Timing, and Player Movement | Per-frame input snapshots, held versus pressed, time-based movement | 6 | 03-Input-Timing-And-Player-Movement |
| 04 | The Playable Wall Path Node System | The core architectural breakthrough: derive the wall from the grid | 12 | 04-The-Playable-Wall-Path-Node-System |
| 05 | Trail Drawing, Self-Intersection, and Fuse Pressure | Temporary geometry, the no-backtrack rule, loops, and the fuse | 23 | 05-Trail-Drawing-Self-Intersection-And-Fuse-Pressure |
| 06 | Capture System, Capturing Logic, and Region Solving | Rasterisation, BFS, the partition guard, region selection, and the root cause analysis (RCA) | 27 | 06-Capture-System-Capturing-Logic-And-Region-Solving |
| 07 | Enemies, Collision, and Fairness | Blended enemy movement, Wanderer, Hunter and Splitter as parameters over one algorithm, two collision tests, lives and respawn | 38 | 07-Enemies-Collision-And-Fairness |
| 08 | UX, Score, HUD, Audio, and Feedback | Scoring, a bitmap font, a cached claimed-area texture, synthesised audio | 45 | 08-UX-Score-HUD-Audio-And-Feedback |
| 09 | Testing, Debugging, and Course Extensions | The three-layer strategy, regression tests, the smoke harness | 45 | 09-Testing-Debugging-And-Course-Extensions |
| 10 | Level Progression, Difficulty Curves, and New Arenas | LevelDefinition, the four-formula curve, presets, pre-claimed insets, and variant rosters scheduled by level data | 50 | 10-Level-Progression-Difficulty-Curves-And-New-Arenas |
| 11 | Powerups, Score Modifiers, and Risk-Reward Systems | Five effect shapes, wall-node spawning, the double-points window | 55 | 11-Powerups-Score-Modifiers-And-Risk-Reward-Systems |
| 12 | Menus, Onboarding, Options, Pause, and Level Selection | The GameStatus state machine and JSON profile persistence | 64 | 12-Menus-Onboarding-Options-Pause-And-Level-Selection |
| 13 | Roguelite Runs, Between-Level Choices, and Persistent Abilities | Three progression layers and the deterministic upgrade draft | 73 | 13-Roguelite-Runs-Between-Level-Choices-And-Persistent-Abilities |
| 14 | Replayability, Daily Challenges, and Telemetry | One seed per day, local statistics, the run summary | 73 | 14-Replayability-Daily-Challenges-And-Telemetry |
| 15 | Themes, Accessibility, and Shipping | ThemePalette, the colourblind override, UI scale, reduced flash, and publishing a build you can hand to someone else | 73 | 15-Themes-Accessibility-And-Shipping |
| Appendix | Where to Take the Game Next | What you could add after the course, and what in the code each idea builds on | (no code) | none |
The "Source" column links each chapter's buildable project in LastPerimeter-Source. The "Tests passing" column is what dotnet test reports in that folder. The count only grows, and every count was verified by building every snapshot.
The course is anchored to the current implementation:
| Area | Code anchors |
|---|---|
| Game loop orchestration | Source/Game/LastPerimeterApp.cs |
| Arena and tile state | Source/Systems/ArenaSystem.cs, Source/Data/GameConfig.cs |
| Playable wall path / node system | Source/Systems/WallSystemV2.cs, Source/Entities/PlayableWallPath.cs |
| Trail logic | Source/Systems/TrailSystem.cs, Source/Entities/Trail.cs |
| Area capture | Source/Systems/AreaClaimingSystem.cs |
| Enemy and collision | Source/Systems/EnemySystem.cs, Source/Systems/CollisionSystem.cs |
| Fuse, score, HUD, rendering | Source/Systems/FuseSystem.cs, Source/Systems/ScoringSystem.cs, Source/Rendering/*.cs |
| Level progression | Source/Systems/LevelProgressionSystem.cs, Source/Data/LevelDefinition.cs |
| Powerups and upgrades | Source/Systems/PowerupSystem.cs, Source/Entities/Powerup.cs, Source/Data/RunModifiers.cs |
| Front-end and persistence | Source/Systems/ProfileStorage.cs, Source/Data/PlayerProfile.cs, Source/Data/GameSettings.cs |
| Themes and accessibility | Source/Data/ThemePalette.cs |
| Replayability and telemetry | Source/Data/PlayerStatistics.cs |
| Validation | Tests/Systems/*.cs, Tests/Game/*.cs |
Suggested delivery
Each chapter states its own time estimate under the title. If you study this as a 10-week module:
| Week | Chapters |
|---|---|
| 1 | 00-01 |
| 2 | 02 |
| 3 | 03 |
| 4-5 | 04 |
| 6 | 05 |
| 7-8 | 06 |
| 9 | 07-08 |
| 10 | 09 |
Chapters 04 and 06 deserve the most time because they cover the path topology and capture solver, which are the two hardest parts of the game.
Advanced extension track
If you follow it with a second 6-week module:
| Week | Chapters |
|---|---|
| 11 | 10 |
| 12 | 11 |
| 13 | 12 |
| 14 | 13 |
| 15 | 14 |
| 16 | 15 + capstone review |
The advanced track turns the course from "build a solid territory-capture game" into "build a flexible arcade platform that can support campaigns, front-end flow, modern retention loops, and future content".
Through-line for every chapter
Use the same five prompts throughout the course:
- What is the player feeling here?
- What runtime state makes that feeling possible?
- Which representation owns that truth?
- What maths or algorithm supports it?
- How do we prove it works?
That keeps the course easy to follow now and reusable later as a published series.
Build snapshots
Standalone, buildable source snapshots for each chapter live in DOCUMENTATION/LastPerimeter-Source/, one folder per chapter from 01-New-Project-And-Basic-Rendering to 15-Themes-Accessibility-And-Shipping. The snapshots are incremental. Each one contains only the files (and staged file versions) that exist at that point in the course. So chapter 05's project compiles without enemies, and chapter 11's compiles without menus.
How they are defined and built:
scripts/chapter-manifest.jsonis the single source of truth: per-chapteraddslists name thelast-perimeter/files that arrive in each chapter, plus a summary of what the chapter's app does.scripts/chapter-files/chapter-NN/holds staged per-chapter variants (most importantly each chapter'sSource/Game/LastPerimeterApp.cs) that are overlaid on the cumulative file set; a later chapter re-listing a path replaces the staged variant with the full version fromlast-perimeter/.- Two special cases: chapter 00 has no snapshot (it is conceptual, with no code), and chapter 09 intentionally shares the chapter 08 build (it studies testing and debugging of the existing code rather than adding runtime code).
Regenerate the snapshots from the current game source in last-perimeter/ on any OS. Run the commands from the repository root:
bash
python3 scripts/generate_chapters.pyor on Windows:
powershell
.\scripts\GenerateChapterProjects.ps1Validate that every snapshot builds and its tests pass:
bash
./scripts/test-chapters.shor on Windows:
powershell
.\scripts\TestChapterProjects.ps1Each chapter's "Chapter snapshot" section states what its build adds over the previous chapter and which test files arrive with it.
Images and tooling
Each chapter's figures live in its own images/ folder, named chNN-* after the chapter. The course overview image above is in DOCUMENTATION/LastPerimeter-Tutorial/images/. Both scripts below write each figure into the right chapter folder:
*.svgdiagrams are generated byscripts/generate-learning-plan-diagrams.pyfrom the real constants and formulas in the code (tile size, arena layout, the difficulty curve, the Bresenham walk, the fuse timings), so they cannot quietly drift from the implementation; rerun the script after changing a number,*.pngscreenshots are captured byscripts/capture-chapter-screenshots.sh, which builds each chapter snapshot, runs it on a virtual X display, drives it with scripted key presses, and grabs frames at the moments the chapters describe (Linux only; the script header lists its requirements and the two captures that used a scratch modification),- flowcharts and state diagrams are Mermaid blocks inside the chapters and render directly on GitHub.

