Shipping a game
Getting a game to people, and keeping its repo alongside Patchwork.
A game is games/<game>/ inside a clone of Patchwork. It reaches players as index.html, the whole game in one tab, or as client.html against <game>.server.ts on node, one seat per page.
Playing it from your machine
- Run
yarn tscand each test file of the game withyarn vitest run <file>, oryarn test:view <file>for a.view.test.tsx. Then playindex.html, andclient.htmlagainst the server. - From the repository root, serve the pages:
yarn vite --host --port <port> --strictPort. Give Vite a port other than 5173, which is the editor's. The pages are athttp://<address>:<port>/games/<game>/index.htmlandclient.html. - With
--host, everyone on the network can read the whole repository except.env,.env.*,*.pem,*.keyand.git. Use it only on a network whose people may. - On the same machine, from the root, run
node --experimental-strip-types games/<game>/<game>.server.ts. It listens onscenemanager.portof<game>.scene.json; that port and Vite's must both be open to the players. - Hand out
index.htmlat the network address for one player, orclient.htmlfor players together, one window each. The editor's address answers only onlocalhost, anddev.htmlis never handed out.
A new game takes one seat; raising it is in Going multiplayer. A player whose machine vanishes without closing the socket holds the seat until the operating system gives up on the connection.
Going online
- A static host (GitHub Pages, itch.io, a CDN) needs an export of the game, a site written from the game's files. The repository itself, or
vite build'sdist/, shows a blank page. - The export holds the pages' imports as JavaScript, every file the pages load while they run (each scene's sim, each
<kind>.client.ts, the game's own plugins, each.actors.json), and every catalogue file at its path from the host's root,/games/<game>/assets/<game>.json. - Serve the site at the host's root, not a subpath, and send the
.tspaths with a JavaScript content type. - For
client.html, run the server on the machine that serves the pages, from a clone withyarn install, on Node 22.6 or later. The page dialsws://on the host it came from, so a page served overhttps://cannot reach it.
Your repo and Patchwork
A game's repo is made with git clone --origin upstream https://github.com/outsidedata/patchwork.git <game>. upstream is Patchwork, which you read from. Add your own with git remote add origin <url> and git push -u origin master. games/<game>/ is committed like any other folder.
Taking Patchwork's updates
git fetch upstream, thengit switch -c update-core.git merge upstream/master. On a conflict, write what the lines should be and commit, orgit merge --abort. Foryarn.lock, rungit checkout --theirs yarn.lockand thenyarn install.- Run
yarn installandyarn tsc, then the test beside each file ingit diff --name-only master update-core, then the game's tests. - If the pages changed, write the game's pages again in the new shape with the game's names.
yarn tscnever checks a page, so playindex.htmlandclient.html. git switch master,git merge update-core,git push origin master.
Giving back
A plugin, addon, editor extension, script or edit to a Patchwork file that names no game can go back as a pull request. The engine itself is never a pull request; a feature that needs it is an issue.
- Fork once:
gh repo fork outsidedata/patchwork --clone=false, thengit remote add fork <url>. git fetch upstream, thengit switch -c give-<name> upstream/master.git checkout master -- <path>for each folder and file that goes, with its tests. Commit.- Run
yarn install,yarn tscand its tests on that branch, where no game is in the tree. git push fork give-<name>, thengh pr create --repo outsidedata/patchwork --base master --head <you>:give-<name>.- Once it is merged, take Patchwork's updates and keep its version of each file the merge stops on.
Checking it
yarn tscand every test file of the game, including<game>.sim.test.ts,<game>.server.test.tsand<game>.predict.test.ts.- Played at the network address, not
localhost:index.html, thenclient.htmlin two windows or on two machines, each player's thing moving on the frame after the key and each seeing the other move. - An export played from a static server that sends
.tsas JavaScript.