EARTH GAMESVARHAINEN PÄÄSY
Home›Developers
API v1 · SANDBOXED JS FREE TO BUILD

Build multiplayer games on the real world

One game.json manifest and one server.js rules script. Write event-driven JavaScript, hot-reload into a live 1:1 3D world in ~1 second, and skip graphics, netcode, and UI boilerplate.

$ npx earthgames new my-game
types (.d.ts)
my-game/server.js
js
const found = new Map();
 
export default {
  onPlayerJoin(player) {
    found.set(player.id, 0);
    eg.ui.toast(player, 'Find the flag.');
    const at = eg.world.offset(player, 0, -60); // 60 m north
    eg.entities.add({
      id: 'flag-' + player.id,
      kind: 'zone',
      at,
      radius: 6,
      label: 'Flag',
      visibleTo: player,
      trigger: {},
    });
    eg.ui.waypoint(player, at);
  },
  onZone(player, entityId, what) {
    if (what !== 'enter') return;
    const score = (found.get(player.id) || 0) + 1;
    found.set(player.id, score);
    eg.ui.hud(player, [{ type: 'counter', text: 'Flags', value: score }]);
  },
};
Surface Area21 Namespaces · 173 CallsPlus 15 lifecycle events and 12 HUD parts
Dev Feedback Loop~1s Hot ReloadSave server.js to reload active instances in place
Server Isolation32 MB / 8 msSandboxed QuickJS runtime per running match or world
Editor IntelligenceZero-Install .d.tsTyped eg.* globals and handlers via jsconfig.json

How the runtime works

A game is a folder with two files: game.json declares metadata, player modes, and content flags, while server.js exports event handlers. The platform handles 3D rendering, physics, vehicles, combat validation, and networking — your script calls eg.* to shape the rules.

1 · LocalEditor + TypeScript

Scaffold with earthgames new. Get full eg.* autocomplete from bundled earthgames.d.ts.

2 · Watchearthgames dev

Validates locally, pushes drafts to your private dev slot, and streams live server logs to your terminal.

3 · SandboxIsolated Server VM

Runs one VM per instance. Reacts to joins, zones, combat, races, and timers within strict CPU budgets.

4 · World1:1 3D Clients

Pushes zones, NPCs, HUD cards, menus, waypoints, and audio cues to everyone in your match.

Explore real shipped games

Every game below runs on the public eg API and ships inside the SDK. Inspect the real rules scripts or scaffold one locally in one command.

All source files →
sdk/templates/blank/server.js
js
// The rules of your game. This file runs on Earth Games' servers, once for each running copy of
// the game. It reacts to events (a player joined, entered a zone, pressed a button) and calls
// `eg` to change the world and what players see. The full list: docs/api.md, or hover in your editor.
//
// This starter puts a flag 60 metres north of wherever each player starts and counts who reaches it.
// Nothing in it is a fixed coordinate, so it plays anywhere on Earth.
//
// Text players see goes through eg.t('…'): it reaches each player in their own language once the game
// has translations (your own in lang/<code>.json, see docs/guide.md "Translating your game").
const found = new Map(); // player id → flags reached
 
function hud(player) {
  eg.ui.hud(player, [
    { type: 'title', text: eg.t('My Game') },
    { type: 'counter', text: eg.t('Flags'), value: found.get(player.id) || 0 },
  ]);
}
function placeFlag(player) {
  const at = eg.world.offset(player, 0, -60); // 60 m north of them
  eg.entities.add({ id: `flag-${player.id}`, kind: 'zone', at, radius: 6, label: eg.t('Flag'), style: 'default', radar: true, visibleTo: player, trigger: {} });
  eg.ui.waypoint(player, at, { hint: eg.t('Walk into the ring') });
}
 
export default {
  onStart() {
    console.log('The game started.'); // shows in "earthgames dev" and in the in-game console (only you see it: no eg.t)
  },
  onPlayerJoin(player) {
    found.set(player.id, 0);
    eg.ui.toast(player, eg.t('Find the flag, {name}.', { name: player }), 'info');
    hud(player);
    placeFlag(player);
  },
  onZone(player, entityId, what) {
    if (what !== 'enter' || entityId !== `flag-${player.id}`) return;
    const n = (found.get(player.id) || 0) + 1;
    found.set(player.id, n);
    eg.audio.cue(player, 'ui.job_deliver');
// ... full source on /developers/examples#blank
Minimal starter: spawns a flag 60 m north of each player anywhere on Earth and updates their HUD.
Read full source →

Start in five minutes

  1. Turn on maker mode & mint a token

    Open your Account Developer Console, accept the maker rules, and generate a token (egdev_…).

  2. Scaffold a project (Node.js 20+)
    setup
    sh
    $ npx earthgames new my-game
    $ cd my-game
    $ npx earthgames login --token egdev_…
  3. Run it live on the 3D world

    Checks your manifest and script, uploads a private draft, and prints a direct launch URL.

    watch & reload
    sh
    $ npx earthgames dev
  4. Edit & hot-reload with live telemetry

    Save server.js and your running match restarts in ~1 second with you still inside. Script output from console.log streams to your terminal and the in-game console (` key).

  5. Test multiplayer before publishing

    Drafts run in a private copy of the world. Share the invite code with friends to playtest together — zero review required for private drafts.

Built-in platform systems

eg.world & eg.spawnersPlays anywhere on EarthPlace objectives with bearings, radius queries, weather presets, and real shops or streets via placesNear — zero hardcoded coordinates.Explore spatial APIs → eg.npcsAutonomous AI crowdsDefine character kinds and behaviors (chase, guard, patrol, flee). The engine handles pathing and hundreds of active NPCs.Explore NPC APIs → eg.combat & eg.inventoryServer-authoritative combatEnable health, armor, weapons, damage, explosions, fire/confetti/ring FX, and custom items in one call. Hit detection runs server-side.Explore combat APIs → eg.ui & eg.audioRich HUDs, windows & modalsShow structured multi-block windows, awaitable confirms/forms, banners, countdowns, badges, chat announcements, and haptic feedback.Explore UI APIs → eg.saves & eg.scoresPersistence & leaderboardsStore per-player progress across matches, run persistent multi-day worlds, and publish weekly/all-time scoreboards.Explore persistence APIs → eg.raceStreet & custom racingOffer tracks built from real streets or define custom gate courses with synchronized start lights, splits, and class par times.Explore racing APIs →

Sandbox model & guarantees

Limits are transparent live budgets — visible in real time inside the in-game dev console — rather than guesswork.

What your script controls

  • Full control over entities, spawners, combat, teams, races, saves, and UI inside your running instance.
  • Cross-session player persistence and persistent world state with automatic save hooks (onLoad).
  • Live telemetry in your terminal and the in-game dev panel (`): console output, handler CPU ms, and dropped events.

Security & runtime boundaries

  • Zero network access (no fetch), no filesystem access, and no arbitrary HTML injection into player pages.
  • Player privacy by design: scripts see only a display name and a game-scoped opaque ID.
  • Single-file ES module (server.js) with deterministic turn budgets (8 ms / handler); use eg.timers and eg.world.now().

Publishing & maker rewards

Run npx earthgames submit when ready. Every submission is reviewed by the Earth Games team before going live on Games with its own URL (/games/<id>) and maker profile. Updating an approved game bumps "version" while players stay on the live build until review finishes.

Developer
Turn on maker mode.
The Developer role on Discord and its channels.
Published Developer
Have one game live.
4 build requests a month instead of 1.
Rising Developer
A game with 25 players and 20 hours played in a month.
1 month of Earth Pass.
Star Developer
A game with 150 players and 200 hours played in a month.
3 months of Earth Pass.
Legend Developer
3 Star months in a row.
6 months of Earth Pass.

Rewards are discretionary thank-yous (no revenue share). See full reward rules or check live monthly stats in your Developer Console.

No code? Build right inside the 3D world

Press P in Earth Games and open Make a game to place zones visually, wire rule cards, playtest with friends, and submit for review.

Read the no-code guide →

Documentation & machine-readable SDK

01 · GuidesHow-to cookbookWorking recipes for anywhere-play, NPC waves, combat loadouts, menus, rounds, saves, and races.Read guides → 02 · ReferenceSearchable API referenceEvery lifecycle event, eg.* method, signature, and HUD part generated from the runtime table.Search API → 03 · Manifest & Specsgame.json, assets & limitsManifest schema, live marker color swatches, weapon stats, character models, sounds, and budgets.Inspect specs →
COMMUNITY & VOICE CHAT

Join the Earth Games Discord

Voice chat for heists, convoys and Cannonball races, live town launch pings, daily photo/place trivia, and in-game chat. Joining unlocks the Discord Explorer badge, +25 Credits, and 5× town votes.

Founding community · Voice & convoys
Join the DiscordFree · +25 Credits on link