# The platform contract This page is the whole set of rules. There are two kinds, and the line between them is kept on purpose: - **Platform requirements are mandatory.** A version that misses one cannot go live; `publish` refuses it and says exactly what to fix (`publish {dry_run: true}` lists every requirement with its status). They are the hard rules below, plus the store metadata, content and originality checks further down. - **Game design is yours.** Which way up the game is played (landscape only, portrait only or both), how it lays out its interface, its art, cover, loading screen and sound are design decisions. The platform's game standards and the other guides recommend how to fit around the platform's own surfaces; they are advice you can take or leave, and no recommendation ever stops a version. ## The hard rules (platform requirements) 1. **A game is a web page.** The platform hosts web games only: native, mobile, console and desktop builds, installers and archives are refused at upload, and a page that sends players to a download, an app store or another site fails the static checks. From an engine, upload its Web / HTML5 / WebGL export. `index.html` sits at the root of the bundle. Everything it loads from the bundle uses relative paths (`./src/main.js`, `assets/tiles.png`). There is no build step on the platform: what you upload is what is served. If you want a bundler, run it yourself and upload the output. 2. **Call `GCP.ready()` once**, right after the first frame a player could act on is drawn. Not at script start, not when a menu is still loading. 3. **Stay alive.** After ready the page must keep answering, must not throw uncaught errors, and must survive keyboard, mouse and touch input. A game with an animation loop drives it from `requestAnimationFrame`; a game that redraws only when the player acts (a sandbox, a drawing toy, a board or card game) needs no loop. 3b. **Be playable.** A game reacts to the player and keeps running whatever the player presses. Verification checks both (`input_handled`, `bot_play` below), and `publish` refuses a version that fails one: - Make every press visibly do something (move, aim, select, shoot, a menu highlight). The verifier presses arrows, WASD, Space, Enter, J, K, Z, X, clicks, drags and taps in the play area and compares the screen with what changes when nothing is pressed. If the game opens on a title screen, register `GCP.test.onAutostart` to drop into play. When the whole screen moves by itself anyway, `GCP.test.onState(fn)` returning what the player changes (position, selection) is read instead. - Keep running through bot play: random keys, clicks, drags and taps for about 45 seconds (`get_started` shows this platform's number). No uncaught errors, no frozen page, no leaving the page (a loop that stops because the game only redraws when played is fine). Restarting by reloading ("Play again") is fine when it boots again. - A score, a goal or an ending is **optional**, and so is `GCP.gameOver`. Sandbox, toy, idle, creative and exploration games can have none of them, nothing needs declaring, and no check refuses a game for what kind of game it is. A game that has one reports it with `GCP.score(n)` when the score changes and `GCP.gameOver({ outcome: 'win' | 'lose' | 'done', score })` when a run, level or match ends (`GCP.leaderboard.submit` and a `GCP.test.onPlaythrough` that plays to the end count too); the store then ranks it a little higher (`score_or_end` below, advice only). 4. **Play on computers, tablets and phones.** Every game on the platform must be playable on every kind of device it supports: with a keyboard or a mouse on a computer, and by touch on a phone or tablet (touch controls of your own, or the platform's on-screen controls pressing your keys). Declare `"devices": ["desktop", "tablet", "mobile"]` in `requirements`. Verification plays every version on an emulated iPhone and iPad, and it must start, keep answering, respond to taps and a drag and throw no errors there (redrawing all the time is not required). `publish` refuses a version that leaves a kind of device out (rule `every_device`). Which way up it is played is your choice (`orientation`): a landscape-only or portrait-only game meets this rule. 5. **Fit the game's storage.** All of a game's files together may use the game's storage (50 MB by default, the largest file 20 MB; `get_started` shows this platform's numbers under `storage`). Uploads that would go over are refused, and a version over it cannot be deployed or published. Generate content from code, load large or optional content at run time from your own host, and tell the developer about the limit when planning. `get_started {topic: "storage"}`. Recommended, not required: **hand over the frame.** Draw everything the player sees (the world, the HUD, menus, dialogs, text) in your canvases, never as page elements over the game, and register `GCP.test.onCapture(fn)` and `GCP.test.onState(fn)` (text fields are the one exception). The creator's feedback screenshots need it; the `capture` check reports it as advice and never stops a version. See "Hand over the frame" below. That is all. Genre, art style, camera, orientation, engine, rendering technique, file layout, controls and the look of the UI are yours; the UI is drawn in your canvases. ## What the platform gives the page The platform serves each version of a game from Cloudflare's network on the game's own origin (one for the preview, one for the live game), and adds two things to the top of `index.html` before any of your code runs: - `window.GCP`, the SDK. Never import or bundle it. Guard for local testing with `if (window.GCP) GCP.ready();`. - An import map, so these bare imports work with no bundler: ```js import * as THREE from 'three'; // Three.js 0.187.0 import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; import * as THREE_GPU from 'three/webgpu'; // WebGPU build import { createLoop } from '@gcp/core.js'; // optional helper modules the platform hosts ``` If your `index.html` has its own ` ```