Appearance
Build Last Perimeter with MonoGame
Welcome to Last Perimeter, a type-along course. You build a complete 2D arcade game from an empty project, one service and one operation at a time, and you prove every rule with a test.
Last Perimeter is a territory-capture game. You steer a marker along the edge of a field, leave the edge to draw a risky line, and reconnect to claim the space you enclosed. Enemies roam the open field, and a fuse chases you whenever you stop. Claim enough of the field and the level is won.
By the end of the course, you have a finished game with levels, powerups, menus, saved profiles, upgrades between levels, a daily challenge, colour themes and accessibility options. You also have a test suite that proves its rules without opening a window.
Last Perimeter is an independent game inspired by Qix (Taito, 1981). It is not affiliated with or endorsed by the owner of Qix.
Who this course is for
This course is for developers who write C# with confidence and have never used MonoGame or built a game. You should be comfortable with classes, properties, records, collections and basic generics. You do not need any maths beyond school geometry.
If you are newer to C#, read the optional C# primer first. It explains each language feature the course uses, with a short example and the chapter where you first meet it.
You do not need to know anything about game loops, sprites or tile grids. The course explains each one before you use it.
What you will learn
- How a MonoGame project starts, updates and draws, and why the host class stays thin.
- How to split a game into services that each own one kind of truth.
- How to write a contract for an operation, then a test, then the code.
- How to draw everything from one white pixel, with no art assets.
- How to solve real problems: rebuilding a wall path, ruling a trail, steering enemies and choosing which region a closed line captures.
- How to prove game rules headlessly, with scenario tests that need no window.
- How to build the product around the game: menus, profiles, saving, seeded runs, themes and shipping.
Prerequisites
You need four things. Complete each step before you start Chapter 01: The Project and the Host.
A code editor. Visual Studio Code with the C# Dev Kit extension is a good choice. Visual Studio and JetBrains Rider also work.
The .NET 10 SDK, from the .NET download page. Open a terminal and run
dotnet --version. The output should start with10..The MonoGame project templates. In a terminal, run the following command, then check the result.
dotnet new install MonoGame.Templates.CSharp dotnet new list monogameThe second command should list the MonoGame templates.
A clone of the course repository. The repository holds the course text and a finished project for every chapter.
In PowerShell, run:
powershellcd $HOME git clone [TODO Simon: public repository address] last-perimeter-course cd last-perimeter-course pwdIn bash, run:
bashcd ~ git clone [TODO Simon: public repository address] last-perimeter-course cd last-perimeter-course pwdThe last command prints the path of the clone. This course calls that path
<course-repo>. If you prefer not to use Git, download the repository as a ZIP file from its web page and extract it, then note the path of the extracted folder.
NOTE
You build your own game in a new folder named LastPerimeter, created in Chapter 01. The course repository is a reference. Open it when you want to compare your work, not to copy from it.
How each chapter works
Every chapter from 01 onward is type-along. Chapter 00 is reading only.
Chapters from 03 onward build services. Every operation of every service follows the same five steps:
- Read the contract card: what the operation takes, gives, promises and refuses.
- Add the signature, with a body that throws
NotImplementedException. - Add the tests, one per promise and one per refusal, and watch them fail.
- Write the body, and watch the tests pass.
- Read the explanation, headed "The key things to note are:".
The tests come first because a test that has never failed has never proved anything. The stub keeps the project compiling, so each failure is a clean one.
Every chapter has the same sections, in the same order:
- A navigation line, an introduction and the end-state figure, with a time estimate.
- The requirements the chapter builds.
- Concept sections that explain the ideas before any code.
- One section per service, with one subsection per operation.
- Wiring the service into the game.
- Running the tests, with the exact count to expect.
- Running the game, with the keys to press and what you should see.
- Common mistakes, a conclusion, Test Your Knowledge and extensions.
Chapter 00: Overview explains this shape in more detail and shows the service map of the finished game.
The through-line
Every chapter asks the same six questions:
- What is the player feeling here?
- Which requirement makes that feeling possible?
- Which service owns that truth?
- Which operation changes it, and what does that operation promise?
- What maths or algorithm supports it?
- Which test proves it?
Chapter map
The course has 22 chapters in three parts. Each part ends with something you can play.
Part 1: Foundations
You finish with a thin host, a scene manager, the arena service, input, and a headless simulation that moves a dot.
| Chapter | Title | What you build |
|---|---|---|
| 00 | Overview: the game, its requirements and its services | Nothing. This is a paper chapter. |
| 01 | The project and the host | LastPerimeterApp, GameLaunchOptions |
| 02 | Drawing from one pixel | PrimitiveDrawing, PlayerRenderer |
| 03 | The service pattern and the arena | GameConfig, ArenaSystem |
| 04 | Input and frame time | InputManager, InputState, MovementSystem |
| 05 | Scenes and the gameplay simulation | Scene, SceneManager, GameServices, GameplaySimulation |
Part 2: One complete level
You finish with the whole core loop: wall path, trail, fuse, capture, enemies, lives, score, HUD and sound, with scenario tests that drive the simulation without a window. Chapters 06 and 09 are the hardest, so allow the most time for them.
| Chapter | Title | What you build |
|---|---|---|
| 06 | The wall path service | WallSystemV2, PlayableWallPath |
| 07 | The trail service | TrailSystem, Trail |
| 08 | The fuse service | FuseSystem |
| 09 | The capture service | AreaClaimingSystem, ClaimedAreaRenderer |
| 10 | Enemies and collision | EnemySystem, CollisionSystem |
| 11 | Lives, shields and respawn | LivesSystem |
| 12 | Events, score and feedback | GameEvent, ScoringSystem, AudioCuePlayer, HudRenderer |
| 13 | Proving the level | ScriptedInput, scenario tests, the smoke run (LASTPERIMETER_SMOKE_TEST_SECONDS) |
Part 3: The full game
You finish with levels, powerups, profiles, menus, runs and upgrades, seeded daily runs, themes, accessibility and a shipped build.
| Chapter | Title | What you build |
|---|---|---|
| 14 | Levels and difficulty | LevelProgressionSystem, LevelServices |
| 15 | Powerups | PowerupSystem, PowerupEffects |
| 16 | Profiles, settings and saving | ProfileStorage, ProfileTracker |
| 17 | Menus and the front end | MenuList, OptionsModel, the menu scenes |
| 18 | Runs and upgrades | RunModifiers, RunUpgradeDraft |
| 19 | Seeds, the clock and the daily challenge | DailySeed, RunRandom, PlayerStatistics |
| 20 | Themes and accessibility | ThemePalette, the options rows |
| 21 | Shipping | Publishing, continuous integration and the requirements sign-off |
Reference
These pages are not numbered chapters. Use them whenever you need them.
| Page | What it gives you |
|---|---|
| C# primer | An optional guide to the C# features the course uses, with the chapter where each first appears. |
| Requirements of the finished game | Every requirement, its acceptance check, its proof and the chapter that builds it. |
[TODO Simon: decide whether the course ships an appendix, "Where to take the game next", and where it links from this page]
Suggested pace
The chapters group into six blocks. Each block is a sensible stopping point.
| Block | Chapters | Notes |
|---|---|---|
| 1 | 00 to 02 | MonoGame from zero. |
| 2 | 03 to 05 | The patterns every later chapter repeats. |
| 3 | 06 to 09 | The two hardest chapters are 06 and 09. |
| 4 | 10 to 13 | Ends with a complete, tested single level. |
| 5 | 14 to 17 | Content and the front end. |
| 6 | 18 to 21 | Product features and shipping. |
[TODO Simon: total course time and a time estimate for each block]
Where the snapshots live
Each chapter from 01 onward has a snapshot: a complete project folder that matches the end of that chapter. The snapshots are in the course repository, in DOCUMENTATION/learning_plan_2/snapshots/, one folder per chapter. Chapter 00 has none, because it has no code.
If your project fails to build or a test count differs from the chapter, compare your files with the snapshot for that chapter. To build a snapshot, open a terminal in its folder and run dotnet build. To test it, run dotnet test.
IMPORTANT
Use a snapshot to find a difference, not to skip the typing. You learn the rhythm of the course by writing each test and each body yourself.
Start the course
When the four prerequisites are in place, begin with Chapter 00: Overview. It takes no typing, and it explains the words the rest of the course uses.

