Skip to content
All topics · Start here

Start here

How a work is made for Playspace: what it is, the three starters you can begin from, and the rules every page keeps.

What Playspace is

Playspace is a place on the web where people play small interactive works from a link: games, toys, scenes, pieces, stories. A work is a folder of web files (an index.html and what it loads) that runs in the browser with nothing of yours behind it; Playspace hosts it and gives it the same few controls on every phone and computer.

A work does not have to be a game. Nothing here assumes a score, a death, a level or an ending.

The three starters

  • plain (plain.zip): canvas 2D, no library. Wisp, a light you steer through a pond of motes.

  • Phaser (phaser.zip): Phaser 4.2.1, in vendor/phaser.min.js, one scene with Arcade physics and textures drawn from shapes. Marbles, a table of marbles you roll among.

  • three.js (three.zip): three.js r187, in vendor/three.module.js and vendor/three.core.js, loaded with <script type="module">. Garden, a small low garden you walk through and look around.

Write for the vendored version's API, not a newer or older one; THIRD_PARTY.md in the Phaser and three.js folders names it.

Each listens to its own keys (W A S D and the arrows, Space, Shift, Esc) and its own pointer, as any web page does, and playspace.json's controls (the control manifest) tells Playspace which of those keys the stick, A, B and the menu pill press. Beside that each makes a few calls: playspace.ready() when its first frame is drawn, playspace.start() at the first touch or key, playspace.on("pause") and on("resume") to hold still and go on, on("mute") to keep its own sound state with the player's Sound switch, and one playspace.moment(). On a touch screen each also answers doubleTap and dash through playspace.input.onIntent (the player's default for both would press B's Shift). The three.js starter looks around with playspace.camera.onLook: with Playspace there, a drag (a finger on a phone, the mouse on a computer) arrives there in radians after the player's own look settings, and the page's own drag reading stays off. Change anything, or start again from nothing and keep only what you need.

Open index.html in a browser to try one (the three.js one from a local web server, as a module page needs: any static server will do). Playspace puts window.playspace on the page when it plays the work; opened on your computer there is none and the page works the same. Keep that guard (if (window.playspace) ...) in anything you write.

The page rules

  • Everything in the folder. Every script, style, image, font and sound the work loads is a file inside the folder. Copy a library in (for example vendor/three.module.js); never load one from a CDN with a <script src="https://..."> tag. The page's Content Security Policy blocks anything from another host.

  • No server. Nothing of yours runs behind the work. Saves and scores go through the SDK (playspace.save(), playspace.load(), playspace.score()).

  • No request to anyone. fetch, XMLHttpRequest, WebSockets and the like reach only the work's own files.

  • You do not add the SDK. Playspace inserts its script into every page it serves, before your scripts, so window.playspace is there when your code runs. Never copy it into the folder.

  • Any shape of screen. Size from the live window (innerWidth, innerHeight) and lay out again on resize (a page opened in a background tab can start at 0 by 0). Never ask for the phone to be turned and never lock the orientation.

  • Sound after a touch. Start or resume your AudioContext on the first touch, click or key.

  • Moments. Call playspace.moment("snake_case_name") where something meaningful happens in the work's own terms (a choice made, a thing finished, a place reached), after playspace.start() and for something a person did: rarely, never every frame. That call is all; the publishing agent declares it.

  • The limits. At most 100 MiB unpacked, and as one upload; at most 1,000 files; at most 30 MiB fetched before the first frame is drawn (20 MiB on the phone run); a first frame drawn within 60 seconds.

The same text, plain, for an agent: /sdk/docs/start.md