Skip to content

Lesson 01 — Start the host and draw a frame ​

Where this lesson fits: the game model is still a sketch. This lesson identifies the real executable, the shared game code, and the operations that turn one frame into another.

Time: 2–3 hours

Prerequisites and outcomes ​

Complete lesson 00. By the end, you can build and launch a platform host and trace the MonoGame lifecycle without putting gameplay rules in the host.

Prepare and run ​

  1. Follow getting started. Complete the existing tutorial's chapter 01 setup and steps 1–13, including the three files it tells you to copy.
  2. Open your new LastPerimeter solution folder in your editor and terminal. The commands below run there; do not run them in the course repository's finished game.
  3. Find the chapter 01 staged Source\Game\LastPerimeterApp.cs. The staged app has fewer systems than the final game; use its actual methods for this lesson.

Code anchors ​

  • last-perimeter/Platforms/DesktopVK/
  • last-perimeter/Platforms/WindowsDX12/
  • last-perimeter/Source/Game/LastPerimeterApp.cs
  • last-perimeter/Source/Rendering/PrimitiveDrawing.cs

Guided operations ​

Run commands from your learner project's LastPerimeter solution folder:

powershell
dotnet build LastPerimeter.sln
dotnet run --project Platforms\DesktopVK
dotnet run --project Platforms\DesktopVK -- --smoke-test-seconds 2

If you created the optional WindowsDX12 host, also try dotnet run --project Platforms\WindowsDX12. For DesktopGL, substitute Platforms\DesktopGL as described in getting started.

  1. Open Platforms\DesktopVK\Program.cs (or Platforms\DesktopGL\Program.cs for the fallback) and, if created, Platforms\WindowsDX12\Program.cs. Follow the entry point to LastPerimeterApp; record what the host does not own.
  2. In your staged LastPerimeterApp, find the constructor, Initialize, LoadContent, Update, Draw, and Dispose. Some exit/profile handling is introduced in later chapters.
  3. Identify which objects require a graphics device and which systems can be constructed and tested without one.
  4. Launch the regular app and the bounded smoke run. Observe startup, first frame, and clean exit.

Checkpoint ​

The solution builds and the DesktopVK window renders and closes. You can describe why Draw presents the current state but should not decide whether a claim succeeds.

Common mistakes ​

  • Running a command from the repository root instead of your learner project's solution folder.
  • Adding game rules to a platform host instead of shared source.
  • Assuming an empty Content/Assets folder means the game is missing required art; visuals are procedural.

Questions and extension ​

What must be disposed when the app exits? Compare the two hosts and verify that both use the same game behavior.