Skip to content

Quick start ​

One command makes a project with a game in it: a field, a scout to walk it, a map editor, a server and a test.

sh
npm create @v12-engine my-game -- --yes
cd my-game
npm install
npm run dev

Open the address it prints and click Play. You are Red: click your scout to select it, right-click the ground to send it.

The project installs its packages from npm; what each one is for: Packages.

Make the scout faster ​

Open src/rules.ts. This is the whole game:

ts
export const game = createGame({ id: 'my-game', name: 'My game', checkView: 'throw', tiles, victory: null })

game.unit({
	id: UNIT.scout,
	name: 'Scout',
	kind: 'unit',
	radius: 0.4,
	stats: { health: 100, moveSpeed: 5 },
	sight: 10
})

game.maps({ field: flatField() })
game.onStart((world, { map }) => {
	for (const player of map?.players ?? []) if (player.start) world.spawn(UNIT.scout, { at: player.start, owner: player.id })
})

Change the scout's moveSpeed from 5 to 9 and save. The running game takes the faster scout without a reload.

Give it a body ​

src/view.ts draws the scout from shapes until it has a model:

ts
export const view: GameView<Unit> = {
	units: {
		looks: {
			scout: {
				height: 1.4,
				shapes: [
					{ shape: 'cylinder', size: [0.6, 1, 0.6], offset: [0, 0.5, 0], color: 'team' },
					{ shape: 'sphere', size: [0.45, 0.45, 0.45], offset: [0, 1.2, 0], color: [0.9, 0.8, 0.65] }
				]
			}
		}
	}
}

To use a model, put a .glb in public/ and name it: model: { src: 'scout.glb', scale: 0.6 }.

Make a map ​

  1. On the start screen, click Map editor (or open /?editor).
  2. Raise hills, plant trees, move the start.
  3. Click Save. It writes src/maps/field.vgmap.json.
  4. In src/rules.ts, pass that file to game.maps in place of the field made in code, as the comment there says.

Commands ​

ToRun
Playnpm run dev, then Play
Make mapsnpm run dev, then Map editor, or /?editor
Play on a servernpm run server beside npm run dev, then /?server
Test the rulesnpm test
Check the typesnpm run typecheck
Build the page to hostnpm run build, into dist/

The panel at the top right is the debug panel (pause, speed, fog, spawning), there only while developing.

Next ​