Skip to content
filedom
Esc
↑↓navigate↵open⌘Jpreview
On this page

Pong

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. For the library itself, start with 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:

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

How it maps onto Finder

  • The paddles and ball are Sprites. 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: 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, 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.

Was this page helpful?