# Your first game

> **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release.

In about ten minutes you will have a game you changed yourself, checked, and exported
for the web and the desktop. You start from a finished small game, so there is something
to play from the first minute.

## 1. Get `frost`

[Install `frost`](install.md): download it, unpack it, take macOS's download mark
off the folder (`xattr -dr com.apple.quarantine .`) and put it on your `PATH`. The rest of
this page writes `frost` for it.

## 2. Start from a template

A template is a finished small game. `frost new` copies one into a new folder, and you
change a game that already works.

```sh
frost new mygame
```

That copies `pong`, the smallest: two paddles and a ball, one script. To start from
another, add `--template NAME`:

| Template | Is |
| --- | --- |
| `platformer` | A side-scroller with a tilemap level, a camera and music |
| `arena` | One screen, waves of enemies, a score |
| `breaker` | A brick breaker: three levels as three scenes, capsules, a combo |
| `shooter` | A top-down shooter aimed with the mouse, with a boss |
| `ballast` | A physics puzzle in three rooms: a crate to push, a lift, a seesaw, a cart, a drawbridge on a chain, and darts to hide from |
| `embers` | A third-person game in 3D: a hero to steer with the camera behind it, ramps, pillars, eight embers to gather and two wardens that chase |
| `blank` | One square that moves, with every key of the project file written out, for starting from nothing |

This page uses `pong`. Your new folder holds:

| File | Is |
| --- | --- |
| `game.toml` | The project file: which scene and scripts make the game, the window, the game's own components, the keys |
| `court.toml` | The scene: every entity the game starts with, by name, with its components |
| `pong.luau` | The script: a `step(dt)` function the engine calls sixty times a second |
| `sounds/` | Four WAV files, and the Python script that made them |

All of it is text you can read, apart from the sounds.

## 3. Play it

```sh
frost dev mygame/game.toml
```

A window opens. W and S move the left paddle, Up and Down the right one; first to five
wins. To play in a browser instead, add `--web` and open the address it prints.

Leave it running for the next step.

## 4. Change it while it runs

Open `mygame/pong.luau`. Near the top is a table of numbers:

```lua
local TUNING = {
    ball_speed = 420, -- units a second at the serve
```

Change `420` to `700` and save. The game does not restart: the score and the ball stay
where they were, and the ball is faster from the next serve. `frost dev` prints one line
for each reload, with how long it took. If you save a mistake, the line says what is
wrong and where, the game waits, and it goes on when you save a fix.

This works because what the game must remember is not in the script's local variables:
it is in components (the score is in the entity named `match`) and in the script's
`state` table, and both outlive a reload.

## 5. Add something of your own

Pong counts the hits of a rally but shows nothing. Show the longest rally so far.

First a place to write it. Add this entity at the end of `mygame/court.toml`:

```toml
[best]
Transform = { x = 480, y = 28 }
Text = { text = "", size = 2, color = 0x8f939d, layer = 2 }
```

`Transform` puts it at the middle of the bottom edge (the frame is 960 by 540, the
origin is the bottom-left corner and y grows up). `Text` draws in the built-in font.

Then a script to fill it. Make a new file, `mygame/rally.luau`:

```lua
-- Shows the longest rally so far. `state` outlives a reload and is saved with the game.
state.best = state.best or 0

function step(dt)
    local rally = get(find("ball"), "Ball", "rally")
    if rally > state.best then
        state.best = rally
        set(find("best"), "Text", "text", "LONGEST RALLY " .. state.best)
    end
end
```

`find` looks an entity up by the name the scene gave it; `get` and `set` read and write
one field of one component. `Ball` is a component this game declares itself, in
`game.toml` under `[components]`.

Last, tell the project about the script. In `mygame/game.toml`, change the `scripts` line to:

```toml
scripts = ["pong.luau", "rally.luau"]
```

A new entity or a new script is read when the game starts, so stop `frost dev` (close the
window) and start it again. From then on, saving `rally.luau` reloads it like any other.

## 6. Check it without playing

```sh
frost check mygame/game.toml
```

lists what is wrong with your game without running it: a key the project file does not
know, a component a scene names that nobody declared, a script that does not parse, a
picture that is missing. One problem a line, with the file and the line.

A game can also be run with no window, for a test or a picture:

```sh
frost run --headless --steps 2124 --shot end.png --state mygame/game.toml
```

The template's project file holds a recorded match (`recording`), and `frost run` replays
it: 2,124 steps, the same every time and on every machine. It prints the step count, a
checksum of the world at the end and one of the whole run, and with `--state` what each script keeps in `state`, so
you can see your script worked: `"rally.luau":{"best":4}`. `end.png` is the last frame.

The project file also says what that match comes to (`replay = { steps = 2124, checksum
= "..." }`), and `frost test mygame` holds the game to it and to its `shots`.

The faster ball from step 4 changes how the match goes, so `frost test` now fails: it names
the first step and value that differ. When the change is what you meant, accept it,
then keep the new pictures once you have looked at them:

```sh
frost test --write mygame                          # writes the new checksum
frost check --shots --write-shots mygame/game.toml # keeps the new shots
frost test mygame                                  # passes again
```

## 7. Export it

For the web:

```sh
frost export web mygame/game.toml --out mygame-web
```

writes the folder a static web host serves: a page, the game's files and two builds of
the player, one for browsers with WebGPU and one for the rest. It prints what each kind
of browser downloads. Nothing is compiled: `frost` copies the players that came in its
download. To try the folder, serve it with any static server, for example
`python3 -m http.server --directory mygame-web`.

For the system you are on:

```sh
frost export desktop mygame/game.toml --out mygame-desktop
```

writes the player, named after the game, with the game's files beside it. Send the
folder to someone on the same kind of system; they start the player and it plays. There
is no installer, and nothing is signed.

To put your game on a phone, see [export](../guides/export.md).

## Where next

- [Things and components](../concepts/things.md) explains how a game is put together,
  and the guides go area by area: [2D](../guides/2d.md), [3D](../guides/3d-rendering.md),
  [physics](../guides/physics.md), [input](../guides/input.md), [sound](../guides/audio.md).
- [The scripting reference](../reference/index.md) has every call and component. Offline,
  `frost reference` prints its short core, `frost reference CALL` one entry, and
  `frost reference --search words` finds one.
- Give each kind of thing its own component (`Moth = {}`, `Coin = {}`), and a name to a
  thing there is one of: the editor groups a scene's entities by it, and `each("Moth")`
  finds them.
- The other templates are worth reading even if your game is like none of them: their
  `kit.luau` is a library of helpers to copy and change (tile collisions, a camera that
  follows, animation frames, a key pressed this step).
- Want an AI agent to work on your game? `frost serve mygame/game.toml` and
  `frost mcp mygame/game.toml` let a program play it: step the game, hold keys, read and
  change entities, and take pictures. [For AI agents](../agents/index.md) starts there.
- `frost --help` lists everything `frost` does.
