Install
npm create @v12-engine makes a project to start a game from. It asks what you want, or takes it all from flags.
npm create @v12-engine my-gameThe packages it installs, what each is for and what it exports: Packages.
It asks: where, which starter, the game's name, which parts (editor, tests, shared art, desktop app), which server, ratings, git, and whether to install. Esc or Ctrl+C makes nothing. With --yes, or with nobody to answer (CI, a pipe), it takes the defaults.
Pick a starter
| Starter | What it is |
|---|---|
empty | A flat field and a scout. The default. Quick start walks through it. |
melee | A whole RTS: two races, workers, halls, armies, heroes, gold and lumber, against the computer. |
campaign | Three missions with a hero carried between them. The tutorial builds it. |
examples | What the engine can do, a small scene each, browsed from a list as three.js's examples are. |
Pick a server
--server | What npm run server runs |
|---|---|
single | One game on the first map; the first to join gets the first seat, the computer the rest. The page joins at /?server. The default. |
rooms | Many games on one port (GameRooms): a room per map, a practice room, matchmaking. The page's /?find-game. |
none | No server. |
--ratings keeps a rating per player in ratings.json. See Online, on a server.
Pass flags
npm passes flags after a --; pnpm, yarn and bun take them right after the folder:
npm create @v12-engine arena -- --yes --starter melee --server rooms --ratings
pnpm create @v12-engine duel --yes --server none --no-editor --install| Flag | What it does |
|---|---|
[folder] | Where to make it: empty or new. my-game by default. |
-s, --starter <name> | empty, melee, campaign or examples. |
-n, --name <name> | The game's name. From the folder by default (orc-wars → Orc wars). |
--editor, --no-editor | The map editor at /?editor, saving into src/maps. Without it, none of the editor is installed. |
--server <kind> | single, rooms or none. |
--ratings, --no-ratings | Ratings kept by the server. |
--tests, --no-tests | A Vitest test of the rules. |
--assets, --no-assets | Shared models (@v12-engine/assets). melee, campaign and examples need it. |
--desktop, --no-desktop | An Electron app: npm run app, npm run package (A desktop game, offline). |
--git, --no-git | A git repository with a first commit (not inside an existing one). |
--install, --no-install | Install packages once made. |
--source | Inside the library's own repository: read the engine and client as source. |
--package-manager <npm|pnpm|yarn|bun> | What installs and runs it. The one you ran the command with by default. |
-y, --yes | Ask nothing. |
-l, --list | List the starters. |
-v, --version, -h, --help | Version and help. |
Defaults: empty, editor, single server, no ratings, tests, shared art, no desktop, git, no install.
In code
import { createProject } from '@v12-engine/create'
await createProject('my-game', { starter: 'melee', title: 'Orc Wars', server: 'rooms', ratings: true })It takes the same options (starter, title, editor, server, ratings, tests, assets, desktop, source, packageManager) plus dependencies to override versions. It writes nothing until the whole project is ready; git and installing are the command line's.
How a project is put together
packages/create has a base/ every project gets, a folder per starter in starters/, and a folder per option in layers/. A project is the base, each option's layer, then the starter, laid over each other (package.json is merged). Lines between // @if editor and // @end (or <!-- @if … -->, # @if …) are kept only with that option; !option and a|b work too. The package's tests check that a build has every shared art file its page asks for (files.txt).