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 devOpen 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
- On the start screen, click Map editor (or open
/?editor). - Raise hills, plant trees, move the start.
- Click Save. It writes
src/maps/field.vgmap.json. - In
src/rules.ts, pass that file togame.mapsin place of the field made in code, as the comment there says.
Commands
| To | Run |
|---|---|
| Play | npm run dev, then Play |
| Make maps | npm run dev, then Map editor, or /?editor |
| Play on a server | npm run server beside npm run dev, then /?server |
| Test the rules | npm test |
| Check the types | npm run typecheck |
| Build the page to host | npm run build, into dist/ |
The panel at the top right is the debug panel (pause, speed, fog, spawning), there only while developing.
Next
- Project layout: what each file is for.
- How do I…: add a unit, an ability, a mission.
- Let's make a basic campaign: a whole game, step by step.