Developer documentation
Game SDK v1
Create browser games with Player Games. Generated games use JavaScript and Three.js, with the Game SDK providing controls, local saves, and agent interaction. You do not need to edit source code.
What the SDK means for your game
Describe your game in Creator Hub and test the result. Depending on the game, players can use keyboard or touch controls, pause and resume SDK-enabled play, and use the web player's fullscreen button when their browser supports it. A game can save progress locally on the same browser or device, rather than to an account.
The agent interface lets an agent inspect and exercise the game through its declared actions. This can help with playtesting, but it does not certify that the game works or replace playing it yourself. Older games need an edit that adopts the SDK before they expose agent controls.
The game-first Loom release, including fullscreen and rooms shared with web players, is coming.
SDK reference
The following reference explains the runtime used by generated games. Creators do not need to edit source. Games run with PG and THREE available globally. This example sketches the interface and is not a complete game.
let position = 0;
function moveRight() { position += 1; }
PG.input.bind({ right: ["ArrowRight", "KeyD"] });
PG.loop((dt) => {
if (PG.input.down("right")) moveRight();
});
PG.agent.register({
name: "Example game",
description: "Move right",
actions: {
moveRight: {
description: "Move right once",
parameters: {},
run: () => { moveRight(); return { position }; }
}
},
observe: () => ({ position }),
reset: () => { position = 0; }
});
PG.ready();The game registers the agent interface and calls PG.ready() only when it is playable. Readiness is a game-authored signal, not a guarantee.
Controls and timing
PG.loop(update, render) runs updates at a fixed 60 Hz, caps catch-up at five updates, and pauses in hidden tabs or when paused. It returns a function that stops the loop. PG.input.bind declares keyboard actions and PG.input.down reads them; keys clear on blur or pause. Touch controls use the same game functions. PG.random(seed) supports repeatable resets. PG.lifecycle.paused reports pause state and PG.lifecycle.onChange subscribes to changes, returning an unsubscribe function.
Agent interface
Use PG.agent.register to describe the game, define bounded logical actions, observe its state, and reset it. This interface lets an agent inspect and exercise a game through the same rules as a player. Human controls and agent actions must use the same state and rules. Observations must be side-effect free; reset should be deterministic and must not change saves.
Action parameters are required and support numbers, strings, and booleans, with optional bounds or same-type enums. There can be up to 32 actions and 16 parameters per action. Return finite plain JSON from actions and observations. Calls time out after three seconds, but a timeout cannot stop game code. Restart before retrying a state-changing call.
Local saves
PG.storage.load(), save(value), and clear() use one host-managed local slot per game and browser or device. Saves are not account-based cloud saves. Revisions share the slot, so version and migrate your save format. Save data must be finite plain JSON within 64 KB, 4,096 nodes, and 16 levels of depth. Catch storage failures and do not overwrite an unsupported save.
Multiplayer
Room games use PG.multiplayer.join(), which resolves to a room or falls back to solo play without a host bridge. The room exposes me, players, others, host, isHost, state, and connected. Players can join friends, reconnect, and continue when the host changes. Cross-client rooms with Loom are coming.
room.setMyState(data) publishes player state, room.setState(data) publishes the host's shared snapshot, and room.send(name, data) sends an event to other players. State updates are coalesced at up to 20 per second. room.on(type, callback) subscribes to events including join, leave, host, state, room, event, and disconnect; it returns an unsubscribe function. Player state is limited to 8 KB and room snapshots to 32 KB. The relay does not provide server-authoritative simulation.
Runtime boundaries
Games run in sandboxed frames without account credentials, native handles, arbitrary network access, or top-level navigation. The host manages saves, agent transport, and stopping or restarting the frame. Fullscreen play in Loom is coming. Pause affects SDK-managed loops, not all game code. Observations and readiness are game-authored claims, not certification. The sandbox is not anti-cheat or a hard CPU or GPU limit.