Skip to content

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.

The course in eight frames: the first window, wall movement, the fuse, a capture, an enemy, the HUD, the main menu, and the upgrade draft

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 no global.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.git

If 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:

FolderWhat it holds
DOCUMENTATION/LastPerimeter-Tutorial/this page, and one folder per chapter
DOCUMENTATION/LastPerimeter-Tutorial/NN_chapter_name/index.mdthe 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:

SectionWhat it gives you
Navigationlinks to the previous chapter, this page and the next chapter, at the top and the bottom
Where this chapter fits and Timeone line on what exists before and after, a screenshot of the chapter's end state, and how long to allow
Prerequisites and Learning objectiveswhat to have done, and what "done" means for this chapter
Code anchorsthe real files in the repository the chapter covers
Concept sectionsthe ideas, each under its own heading, with a diagram where a picture explains more than prose
Build it step by stepnumbered steps, each naming its file, with the actual code and the changes to the game class
Chapter snapshotthe buildable folder that matches the chapter, and the exact number of tests that should pass
Checkpointwhat to run and what you should see, with screenshots
What you should have nowa short recap of what exists at the end of the chapter
Common mistakesthe traps, and what you would see if you fell into one
Questions to think about and Extensionsquestions 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 is last-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:

  1. turn an arcade idea into clean runtime systems,
  2. separate simulation, rendering, and temporary geometry,
  3. reason about node paths, rasterisation, and flood fill,
  4. test difficult game logic instead of trusting visuals alone,
  5. ship a game that feels good as well as being technically correct.

Chapter map ​

ChapterTitleFocusTests passingSource
00Overview, Game Idea, and HistoryWhy a territory-capture game is good to learn from; the three kinds of space(paper only)none
01New Project and Basic RenderingMonoGame from zero: the template, the Game lifecycle, one pixel that draws everything301-New-Project-And-Basic-Rendering
02Arena Model and Game State FoundationsScreen layout, the tile grid, world-to-grid quantisation, GameSession602-Arena-Model-And-Game-State-Foundations
03Input, Timing, and Player MovementPer-frame input snapshots, held versus pressed, time-based movement603-Input-Timing-And-Player-Movement
04The Playable Wall Path Node SystemThe core architectural breakthrough: derive the wall from the grid1204-The-Playable-Wall-Path-Node-System
05Trail Drawing, Self-Intersection, and Fuse PressureTemporary geometry, the no-backtrack rule, loops, and the fuse2305-Trail-Drawing-Self-Intersection-And-Fuse-Pressure
06Capture System, Capturing Logic, and Region SolvingRasterisation, BFS, the partition guard, region selection, and the root cause analysis (RCA)2706-Capture-System-Capturing-Logic-And-Region-Solving
07Enemies, Collision, and FairnessBlended enemy movement, Wanderer, Hunter and Splitter as parameters over one algorithm, two collision tests, lives and respawn3807-Enemies-Collision-And-Fairness
08UX, Score, HUD, Audio, and FeedbackScoring, a bitmap font, a cached claimed-area texture, synthesised audio4508-UX-Score-HUD-Audio-And-Feedback
09Testing, Debugging, and Course ExtensionsThe three-layer strategy, regression tests, the smoke harness4509-Testing-Debugging-And-Course-Extensions
10Level Progression, Difficulty Curves, and New ArenasLevelDefinition, the four-formula curve, presets, pre-claimed insets, and variant rosters scheduled by level data5010-Level-Progression-Difficulty-Curves-And-New-Arenas
11Powerups, Score Modifiers, and Risk-Reward SystemsFive effect shapes, wall-node spawning, the double-points window5511-Powerups-Score-Modifiers-And-Risk-Reward-Systems
12Menus, Onboarding, Options, Pause, and Level SelectionThe GameStatus state machine and JSON profile persistence6412-Menus-Onboarding-Options-Pause-And-Level-Selection
13Roguelite Runs, Between-Level Choices, and Persistent AbilitiesThree progression layers and the deterministic upgrade draft7313-Roguelite-Runs-Between-Level-Choices-And-Persistent-Abilities
14Replayability, Daily Challenges, and TelemetryOne seed per day, local statistics, the run summary7314-Replayability-Daily-Challenges-And-Telemetry
15Themes, Accessibility, and ShippingThemePalette, the colourblind override, UI scale, reduced flash, and publishing a build you can hand to someone else7315-Themes-Accessibility-And-Shipping
AppendixWhere to Take the Game NextWhat 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:

AreaCode anchors
Game loop orchestrationSource/Game/LastPerimeterApp.cs
Arena and tile stateSource/Systems/ArenaSystem.cs, Source/Data/GameConfig.cs
Playable wall path / node systemSource/Systems/WallSystemV2.cs, Source/Entities/PlayableWallPath.cs
Trail logicSource/Systems/TrailSystem.cs, Source/Entities/Trail.cs
Area captureSource/Systems/AreaClaimingSystem.cs
Enemy and collisionSource/Systems/EnemySystem.cs, Source/Systems/CollisionSystem.cs
Fuse, score, HUD, renderingSource/Systems/FuseSystem.cs, Source/Systems/ScoringSystem.cs, Source/Rendering/*.cs
Level progressionSource/Systems/LevelProgressionSystem.cs, Source/Data/LevelDefinition.cs
Powerups and upgradesSource/Systems/PowerupSystem.cs, Source/Entities/Powerup.cs, Source/Data/RunModifiers.cs
Front-end and persistenceSource/Systems/ProfileStorage.cs, Source/Data/PlayerProfile.cs, Source/Data/GameSettings.cs
Themes and accessibilitySource/Data/ThemePalette.cs
Replayability and telemetrySource/Data/PlayerStatistics.cs
ValidationTests/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:

WeekChapters
100-01
202
303
4-504
605
7-806
907-08
1009

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:

WeekChapters
1110
1211
1312
1413
1514
1615 + 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:

  1. What is the player feeling here?
  2. What runtime state makes that feeling possible?
  3. Which representation owns that truth?
  4. What maths or algorithm supports it?
  5. 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.json is the single source of truth: per-chapter adds lists name the last-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's Source/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 from last-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.py

or on Windows:

powershell
.\scripts\GenerateChapterProjects.ps1

Validate that every snapshot builds and its tests pass:

bash
./scripts/test-chapters.sh

or on Windows:

powershell
.\scripts\TestChapterProjects.ps1

Each 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:

  • *.svg diagrams are generated by scripts/generate-learning-plan-diagrams.py from 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,
  • *.png screenshots are captured by scripts/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.