Skip to content
Public template

Repository files navigation

Blazor Starter Project

This is the Metaplay starter project for games with a Blazor WebAssembly web client. It contains a small example game that you replace with your own, and it is built to be developed with an AI coding agent.

It is also the base of Metaplay's Blazor samples, Sticky Paws, Table Stakes and Ninja Time Trial, in metaplay-shared/samples. Their project structure, shared code, tools and test harness are this project's, and their documentation refers here for them.

The web client is a regular web app built with C#. A coding agent can build it, run it, and test and inspect it in a browser, without a game engine editor.

Start a game with an agent

AGENTS_GETTING_STARTED.md walks a coding agent from an empty directory to a running game built on this starter project. To use it, start your agent in an empty directory for the project, and paste a prompt like this into it:

Build a game using Metaplay.

Find the detailed instructions in:
https://github.com/metaplay-shared/blazor-starter-project/blob/main/AGENTS_GETTING_STARTED.md

Here is the game I want: <description of the game>

Deploy to the cloud with an agent

AGENTS_FIRST_DEPLOY.md walks a coding agent through the first deployment of the game to Metaplay's cloud. Deploying is optional. When you want to, ask your agent:

Deploy the game to Metaplay's cloud by following AGENTS_FIRST_DEPLOY.md.

What's included

  • Example game: a small clicker game. The player clicks a button to earn clicks, and spends clicks on auto-clickers that earn more clicks over time, including while the player is offline.
  • Web client (WebClient/): a Blazor WebAssembly app for desktop browsers. It has an offline mode that runs without a server. metaplay deploy webclient uploads it to the cloud environment's CDN.
  • Game config (GameConfigSource/, tools/GameConfigGen/): tunable values are CSV files, one file per config entry. tools/GameConfigGen builds them into the server's and the client's config archives. To change a value, edit the CSV file, rebuild the archives, and restart the server.

Run it

Run these from the repository root, each in its own terminal:

metaplay dev server
dotnet run --project WebClient/WebClient.csproj      # or `dotnet watch`, to rebuild the client on changes

Then open http://localhost:5290. Offline mode needs only the web client: http://localhost:5290/?offline

In Rider, the Server + Client configuration under .run/ starts both. In Visual Studio, so does the Server + Client launch profile in Game.slnLaunch, once multi-project launch profiles are enabled (Tools > Options > Preview Features).

Make it yours

Set the web client's name.

  • SharedCode/GlobalOptions.cs: projectName, which WebClient/Program.cs passes to the web client as its appTitle, the browser tab title and the header text. The first deployment sets it to the portal project's name.
  • WebClient/wwwroot/manifest.webmanifest: name and short_name, which the browser shows when the game is installed as an app.
  • WebClient/wwwroot/index.html: <title>, shown while the client loads.

Set its look. ThemeColors in WebClient/Program.cs sets the colors, and WebClient/wwwroot/app.css holds the game's styles, in plain CSS. docs/web-client.md says where the rest are.

Replace the example game

Ask your coding agent to replace the example with your game. The example is marked with comments that start with TODO: Example content, replace with your own. Each comment says what to delete and what to keep. The marked parts are the player state and actions, the config classes and CSV files, the web client's home page and client service, the server's player actor, the bot client, and the tests. List them with:

git grep -n "TODO: Example content"

Documentation

License

Copyright Metaplay. The Blazor starter project is licensed under the Apache License 2.0. The Metaplay SDK it builds on is licensed separately, under the Metaplay SDK License. Third-party fonts keep their own licenses, which are next to them.