Onceworlds
Engine · Posters

Store art: posters

Store art made by the game's own code (game.poster), and pictures to look at (shot).

game.poster(name, setup) registers a staged scene for the game page. Opening the game with ?poster=cover draws that scene instead of the game, at an exact size and a pixel ratio of 1, frozen and deterministic. npx @onceworlds/cli posters opens your latest draft that way and saves a picture of each into store/<name>.png, naming icon and the 16:9 pictures in onceworlds.json when it has none.

game.poster('cover', (p) => {                  // 1920 x 1080 by default; 'icon' is 512 x 512, 'badge-*' 256 x 256
  p.camera({ height: 10, clear: '#203040' });
  p.world.spawn([Transform(), Shape2D({ shape: 'circle', radius: 2, fill: '#ffd23f' })]);
  feelOf(p.world).particles.burst('confetti', { x: 0, y: -4 });
  p.settle(0.8);                               // simulate a little first, with the seed fixed
});

Rules of play leave the poster alone

While a poster is staged, Flow's phase is 'playing', so the HUD and what animates play can pose the scene, and p.settle runs the game's systems, the host's rules included. A rule that only checks the phase runs inside the poster: it starts a wave, drops the pieces you posed or ends the round while the picture settles. Guard every rule of play with the poster as well:

const Waves = defineSystem({
  name: 'waves', stage: 'fixed', authority: 'host',
  run({ flow, world }) {
    if (flow.phase !== 'playing' || flow.poster) return;   // flow.poster: the poster's name while one is staged, else null
    // ... the rule
  },
});

Without Flow, poster?.active says the same in a system (run({ poster })), and servicesOf(game).poster?.active anywhere else. A view that is only for the store (a title over the cover) shows when: () => servicesOf(game).poster?.active === 'cover'.

Pictures to look at: shot

npx @onceworlds/cli shot saves a PNG of the game for you to look at (the MCP tool screenshot returns it to the model directly):