HTML5 / JavaScript integration
A complete dependency-free browser game with acknowledged gameplay events.
Downloads for this guide
HTML5 / JavaScript source packageComplete project and setup notes.Download game.jsIndividual native integration source.Upload-ready HTML5 ZIPRuntime files only. Registration and review still required.Support and prerequisites
Verified in local desktop and mobile-viewport Chromium: the exported starter loaded inside Play Island's real sandbox and completed a run with accepted start, progress and completion events. HTML5 also passed pause/resume and replay. This is not certification for every engine version or physical device. The same per-game event registration and provider approval requirements apply. Download the source package and read README.txt before building. Browser samples never need a secret key.
Set up the project
Extract the package. index.html, client.js and game.js are the entire playable build; there are no runtime dependencies. Use the separate vanilla-upload.zip for submission, or ZIP those three files at the archive root. The source ZIP also contains setup notes and proposed event definitions, which must not be uploaded as executable game configuration. On Play Island, press Start run, collect five stars, optionally pause/resume, wait at least four seconds and finish. The log shows real acknowledgements and any receipts; a standalone browser tab reports that no platform connection exists.
Native integration example
/* Only these registered fields are used: score (integer), progress (0–100).
* No save/purchase/exit methods: they are not generally enabled for new games. */
const status = document.querySelector('#status'), log = document.querySelector('#log');
const start = document.querySelector('#start'), pause = document.querySelector('#pause');
const target = document.querySelector('#target'), finish = document.querySelector('#finish');
let count = 0, running = false, paused = false, busy = false, startedAt = 0, failed = false;
function controls() {
start.disabled = busy || running || failed;
pause.disabled = busy || !running || failed;
target.disabled = busy || !running || paused || count >= 5 || failed;
finish.disabled = busy || !running || paused || count < 5 || performance.now()-startedAt < 4000 || failed;
}
function error(reason) { failed = true; status.textContent = `${reason.message} Reload after fixing the integration.`; controls(); }
async function report(name, data) {
const ack = await PIExample.report(name, data);
log.textContent = `${name}: ${JSON.stringify(ack)}\n${log.textContent}`.slice(0,6000);
}
async function action(work) { if (busy || failed) return; busy = true; controls(); try { await work(); } catch (reason) { error(reason); } finally { busy = false; controls(); } }
start.addEventListener('click', () => action(async () => {
await report('started', {}); count = 0; running = true; paused = false; startedAt = performance.now();
status.textContent = '0 / 5 stars'; pause.textContent = 'Pause';
}));
target.addEventListener('click', () => action(async () => {
count++; await report('progress', { progress: count*20 });
status.textContent = `${count} / 5 stars`; target.style.left = `${10+Math.random()*65}%`; target.style.top = `${10+Math.random()*50}%`;
}));
pause.addEventListener('click', () => action(async () => {
await report(paused ? 'resumed' : 'paused', {}); paused = !paused; pause.textContent = paused ? 'Resume' : 'Pause';
}));
finish.addEventListener('click', () => action(async () => {
await report('score', { score: count*10 });
await report('completed', { score: count*10, progress: 100 });
running = false; status.textContent = 'Run accepted. Rewards, if any, are decided by the server. Start another run to replay.';
}));
PIExample.onReceipt(receipt => { log.textContent = `Server receipt: ${JSON.stringify(receipt)}\n${log.textContent}`.slice(0,6000); });
PIExample.connect().then(config => { status.textContent = `Connected · ${config.locale} · reduced motion: ${config.reducedMotion}`; controls(); }).catch(error);
setInterval(controls,250);Event lifecycle and errors
The project uses the supplied client.js helper to call the real injected PlayIsland SDK. It waits for configuration and acknowledgement callbacks. The helper serializes reports, detects rejected events and stops after a timeout or rejection. It does not manufacture accepted events offline. The example's proposed registry permits score (integer 0–1,000,000) and progress (number 0–100); both are optional in that proposal. Staff must publish the relevant definitions for your game. Other games may have different required fields. Do not copy a built-in game's specialized counters. Wait for real gameplay before reporting completion; the server rejects completed within the first three seconds of a session. Stop after terminal acceptance; use started to begin a new run or reload the launcher. On error, display the reason, correct the problem and reload to obtain a clean sequence.
Test, export and submit
- Test the engine's own rendering and controls locally. A standalone/editor launch will not connect to Play Island.
- Build using the setup instructions above and inspect the resulting runtime files.
- Follow ZIP packaging and provider submission.
- Use the visual preview for loading/layout. Use a published /play/ launch for actual accepted-event tests.
- Verify configuration, accepted start/progress/result, guest behavior, signed-in receipts if configured, replay and mobile controls.
Saves, exit, platform leaderboard navigation and general player profiles are not available automatically to your new game. See feature availability before adding those buttons.
Engine reference
Browser postMessage explains the native engine/browser mechanism. The Play Island contract is defined by the platform implementation, not by the engine documentation.