---
title: Pong
description: Pong played with real Finder icons, in local and networked modes.
---

In Pong the paddles, ball, and score are real files on your Desktop, moved
frame by frame. The source is in the Finder Mode repository under
[`games/pong`](https://github.com/methodacting/finder-mode/tree/main/games/pong).
For the library itself, start with [Getting Started](/docs/learn/getting-started).

## Modes

- Local hot-seat: two players on one keyboard. `W`/`S` move the left paddle,
  `I`/`K` the right, and Return starts or pauses. No server is involved.
- Multiplayer: two machines play over the network, refereed by the game-server
  Worker and a Durable Object. Both sides join a room code. The first connection
  is player 1, the second is player 2, and any others spectate.

`cli.ts` is the single entry point, and its first argument picks the mode. From
the Finder Mode repository root:

```bash
pnpm pong               # local hot-seat
pnpm pong:multi create  # host a room (prints the join command)
pnpm pong:multi join <room>
```

:::info[What happens to your Desktop]
Pong calls `startSession` with the default options, so your existing Desktop items
are hidden in place for the game and shown again when it quits. Pong creates
and deletes only its own sprite files.
:::

## How it maps onto Finder

- The paddles and ball are [Sprites](/docs/reference/components/sprite). Each tick
  updates their positions and the Stage moves the files. Each paddle is two
  sprites, one above the other. The ball has its own Stage, mounted last, so it
  draws above every other file.
- The score cannot be one file whose icon swaps, because Finder blanks on an
  in-place icon change. Each side is a two-place
  [`Score`](/docs/reference/components/score): ten digit sprites per place, parked
  under the cover, with only the active digits moved into view.
- In local play, the net and the field lines are part of a generated
  [Wallpaper](/docs/reference/components/wallpaper), so they cost no files.

## Networked play

The server holds the authoritative state. Clients send paddle moves and render
the `state` it broadcasts. Locally the client connects to a game-server on
`ws://localhost:8787` (`wrangler dev`). Finder Mode injects the deployed
game-server URL and access token through `GAME_SERVER_URL` and
`GAME_SERVER_TOKEN`.
