# Play, pause, step and go back

A Coldwave game advances in fixed steps, sixty a second, and a run of it
[replays exactly](../concepts/steps.md). So in the editor you can stop at any step,
go back to an earlier one, and turn a play you liked into the game's test.

![A run just recorded: the card that names the test, the file it is written to and its shots, over the transport and the timeline](../files/editor/img/play.jpg)

## Play the game

1. Press **Play** in the transport, or `Space` over the game.
2. Click the picture. The keyboard is now the game's, and so is the first gamepad with
   the standard layout.
3. Press `Esc` to take the keys back (the first press lets go of a picked thing).

**How you know it worked.** The line under the picture reads **Keys go to the game · Esc
gives them back**, and the time and step in the transport count up: `0:04.2 of 0:10.0 ·
step 257`.

## Stop and step

1. Press **Pause** (`Space` or `K`).
2. Press **Step** (`.` or `L`) to advance one step, **Step back** (`,` or `J`) to go back
   one.
3. Press the speed to cycle 1×, 2×, 4×, ¼× and ½×.

**How you know it worked.** The step number in the transport changes by exactly one, and
the picture is that step's. Over a paused game the letters are the editor's tools; see
[Keyboard shortcuts](shortcuts.md).

## Going back

1. Press or drag on the timeline. While you drag, the picture follows the pointer through
   everything that was played.
2. Press **Play**. The run past the playhead was kept, so the game plays along it again,
   the same as before.
3. To branch off, do something new at that moment: press a key of the game, save a
   script, or change a value.

**How you know it worked.** The dock's line says how the moment was reached, for example
*Step 14,212 from the keyframe at 14,100: 112 steps*. When you branch, the transport says
**From step 1,800: a new run**, with your keys or your change.

- **Loop** is on unless you turn it off: with a run kept past the playhead, the game plays
  to its end and starts again, the same each time. It waits while a breakpoint is set.
- If you go back to a moment from *before* edits you made by hand, the editor offers
  **Bring them forward**.
- A game that keeps something in a script's `local` instead of its state says **This game
  cannot be wound back quickly**. Going back still works; it replays from the start.

## The run is the test

A game's recorded run is its test: the input of a whole play and what the game comes to.
The editor plays it when the game is up and again after each change. You do not run it;
you read its line at the end of the transport.

1. Read the line. **The run is the test, and it passes** means the game still does what
   the run records.
2. If it reads **The run differs from step 131**, a card over the picture names the step,
   the value, what the recording has, and the line of the script that last wrote it.
3. Press **Go there** to stand the game at that step with **Why?** open on the value. Or,
   if the change is what you meant, press **Accept**.

**How you know it worked.** After a fix or an **Accept**, the line passes again. **Undo**
puts an accepted recording back. The **Tests** tab of the dock lists every recorded run.
[Recorded runs](../concepts/runs.md) explains the idea.

## Record a run as a test

1. Press **Record this run**. The game starts again from step 0 and your keys are kept.
2. Play.
3. Press **Stop recording**. A card asks for the test's name and shows its shots: one at
   the end, and one more for each moment you add with **+** (the moment the playhead
   stands at). **Leave this shot out** removes one.
4. Press **Save the test**. **Throw away** keeps nothing.

**How you know it worked.** The new test is in the **Tests** tab, the count beside it goes
up (`Tests 2/2`), and the tests run again at once.

## Play outside the editor

1. Open the menu beside **Export** in the title bar.
2. Choose **Play in a window** for the engine's own window (its sound, gamepads and real
   speed), or **Play in the browser**.

**How you know it worked.** The game is playing in its own window or tab, and a script you
save in the editor reaches it there too.

## Good to know

- **Saving a script while the game runs** reaches the game as saved: the dock says
  **Reloaded at step N. The game kept running.** See [Code](code.md).
- **Saves** in the dock lists every slot the game keeps between runs; **State** shows what
  each script keeps between steps, read only.
- **When the game is slow**, the dock says how many steps a second it makes, and **Why?**
  opens where the time goes. [Profiling](../guides/profiling.md) has the rest.
- **Hear the game** plays the game's sound in the editor as a preview; the engine's own
  window mixes it exactly.
