How it works
Your game is the guest; the PlayVlay app is the host. The host runs the lifecycle (init → start → pause/resume → restart) and owns all the chrome. The guest only:
- calls
PlayVlay.ready()once it's loaded, - reacts to
onStart/onPause/onResume/onRestart, - calls
PlayVlay.reportScore(n)as the score changes, and - calls
PlayVlay.gameOver(n)when the run ends.
You do not add a <script src> for the SDK — the app
injects window.PlayVlay automatically when your game is uploaded. Just
call the methods. The starter guards every call with if (window.PlayVlay)
so it also runs when opened directly in a browser.
The contract
Host → your game
| Method | When |
|---|---|
PlayVlay.onInit(fn) | Once, before start. fn(ctx) gets { level, difficultyParams, muted, seed }. |
PlayVlay.onStart(fn) | Begin the run. |
PlayVlay.onPause(fn) / onResume(fn) | Freeze / unfreeze. |
PlayVlay.onRestart(fn) | Reset and start again. |
PlayVlay.onSetMuted(fn) | Mute / unmute audio. fn(muted). |
Your game → host
| Method | When |
|---|---|
PlayVlay.ready() | Required. After registering handlers — tells the host it can start you. |
PlayVlay.reportScore(n) | Required. Whenever the score changes (plain integer). |
PlayVlay.gameOver(n) | Required. Exactly once when the run ends. |
PlayVlay.haptic('success') | Optional juice — the host owns the device. |
PlayVlay.track(name, props) | Optional analytics event. |
Rules for a self-contained game
One .html file
Everything inline — markup, CSS, JS. Max 2 MB.
No network
Submitted games run sandboxed (strict CSP). Remote <script src>, fetch, and CDNs are blocked — inline your engine/assets.
Inline assets
Use data URLs / base64 for images & audio, or draw with canvas.
Report score & end
Call reportScore and gameOver — the app can't read your variables.
Starter template
A minimal tap-to-score game wired to the contract. Copy it, open it in a browser to test, then upload it from the Create tab in the app. (The app's “Download starter template” button gives you this same file.)
Submitting
- Open the Create tab in the PlayVlay app (curated creators only).
- Tap Upload and choose your
.htmlfile. - We validate it and auto-add the SDK. Preview it full-screen to test.
- Tap Submit for review. An admin approves it before it goes live in the feed.