1. The project
Goal: a project that runs, with a scout on a field, and the first map saved from the editor.
Make it
npm create @v12-engine my-campaign
cd my-campaign
npm install
npm run devPick the empty starter. Say yes to the map editor, the tests and the shared art (@v12-engine/assets); the campaign is drawn with it. Open the page, click Play, select the scout and right-click the ground.
Look around
my-campaign/
src/
rules.ts the game (createGame): what there is, its map, what happens as a game starts
game.ts the game whole: its look given, fetched as the page first plays it
view.ts how it looks
main.ts the page: the start screen and its scenes
editor.ts the map editor as a scene
tests/
rules.test.ts the rules tested with no page
server.ts a server of the game
vite.config.ts the dev server, the editor's plugin, the shared artThe game is one object, game, exported from src/game.ts. The page, server, editor and tests take it. As the campaign grows it moves into src/campaign/, and game.ts becomes one line:
// src/game.ts, by chapter 3: the campaign's game (src/campaign/game.ts), `createGame(campaign)` with its maps,
// `startMission` as its start and its view
export { campaignGame as game } from './campaign/game'Rules import only the engine, so the same game runs in a page, on a server and in a test. See Project layout.
Save the first map
- Open the map editor (the start screen's button, or
/?editor). - Paint some ground and place a tree or two from Content.
- Press Ctrl+S. It writes
src/maps/field.vgmap.jsonandfield.names.tsbeside it. - Pass the file to
game.mapsinrules.ts, as its comment says.
Rules find things on a map by name (a unit hall, a point camp, a region ford). The names file types them, so a misspelled name doesn't compile.
Play here
The editor's Play here plays the map you're editing with your rules: the fastest way to try a mission.
Next: 2. Units, a building, a hero.