Your first game

A 30-line GAMEE-ready game, line by line.

This is the smallest correct GAMEE integration. Every line that matters has a comment explaining why it exists.

import { gamee } from '@gamee/sdk';

// Local game state. Nothing GAMEE-specific.
let score = 0;
let running = false;
let startedAt = 0;

async function boot() {
  // 1. init() is the handshake with the platform. It MUST be the first SDK call.
  //    The capabilities you pass here gate every other method — declare every
  //    feature your game uses (`saveState`, `gems`, `rewardedAds`, …).
  //    The resolved value is the platform's response: locale, country, save
  //    state, mission data, etc. Use it to localize and resume.
  const ctx = await gamee.init({ capabilities: ['saveState'] });
  console.log('platform says:', ctx.platform, ctx.locale, ctx.country);

  // 2. Subscribe to platform → game events BEFORE telling the platform you are ready.
  //    Otherwise you risk missing the first `start` event.
  gamee.on('start', ({ resetState, gameSeed }) => {
    // The platform fires `start` whenever a new run should begin — first run,
    // restart, replay. You may receive more than one `start` per session.
    score = 0;
    running = true;
    startedAt = performance.now();
    requestAnimationFrame(loop);
  });

  gamee.on('pause', () => {
    running = false;
  });
  gamee.on('resume', () => {
    running = true;
    requestAnimationFrame(loop);
  });
  gamee.on('mute', () => audio.mute());
  gamee.on('unmute', () => audio.unmute());

  // 3. gameReady() tells the platform that the canvas is up and responsive.
  //    The platform won't dispatch `start` until you call this.
  gamee.gameReady();
}

function loop() {
  if (!running) return;

  // ... your game logic ...
  score += 1;

  // 4. updateScore() is fire-and-forget — call it as often as the score
  //    changes. The 3rd argument is the anti-cheat checksum for the run.
  //    Compute it however you like; the platform treats it as opaque.
  gamee.updateScore({ score, playTime: (performance.now() - startedAt) / 1000, checksum: 'mychecksum' });

  if (score >= 1000) return endRun();
  requestAnimationFrame(loop);
}

function endRun() {
  running = false;

  // 5. gameOver() ends the run. Optional `saveStateData` is auto-stringified;
  //    `rewardIds` ties this run to mission/level rewards if any.
  gamee.gameOver({ saveStateData: { highScore: score } });
}

boot();

That’s it. You now have a game the GAMEE platform can launch, pause, resume, mute, score, and end.

What to add next#

  • Save & resume — declare saveState, write at game-over, read from ctx.saveState at boot. See capabilities.
  • Rewarded videos — declare rewardedAds, call gamee.showRewardedVideo() on extra-life prompts.
  • In-game purchases — declare gems, call gamee.purchaseItemWithGems(...).
  • Custom analytics — declare logEvents, call gamee.logEvent({ name, value }) (or just gamee.logEvent(name)).

See the events page for the full platform → game catalogue and what you must do for each.

Switch to a desktop

The GAMEE SDK emulator and docs are built for screens wider than 1280 px. Open this page on a laptop or desktop browser to get the full experience.

If you're already on a wide screen, drag your window wider and this banner will disappear.