vibes.diy Make an app → Discord
creator docs · reference · generated

Surface: the play area — the look reaches a full-screen game

This is the same document the Vibes code generator reads when it builds apps — rendered from prompts/pkg/llms/surface-play-area.md on every deploy, so it can't drift from what the platform actually does. Read it from your terminal any time with npx vibes-diy skills.

The look reaches the play area: the canvas paints with the app's own tokens, or with the sky and light of the place the person named, and the HUD over it is the kit's components on the look's surfaces.

A full-screen game is judged by its first screenshot, and that screenshot is mostly canvas. The world, the overlays, the hotbar and the buttons all speak the look, so the game reads as the same crafted app as everything else the person made.

A named place paints its own world. When the person names where or when the game happens (a mountain temple at dusk, a city at night, a reef at noon, floating islands), the sky, fog and light come from that place. The look still owns everything the player reads and presses (the HUD, the title, the buttons), and the player and the thing to chase keep lead and accent, so the game is still the person's app. Wherever this skill, or a game skill beside it, paints the sky, fog, light or a day/night cycle from readLook, a named place paints them from its own colours instead, and watchLook repaints the HUD, the player and the goal on a restyle while the place keeps its sky.

  • A 3D world writes the sky once as a GLSL function of the view direction, in the place's own colours, and calls it from a back-side sky dome (SphereGeometry(900), side: THREE.BackSide, depthWrite: false, fog: false, following the camera) and from three's fog, so every distant shape melts into the sky behind it. Replace the fog chunks once, before any material compiles:

    js// The place's colours (a temple at dusk here) and a normalized sun, written into the GLSL itself
    // so the dome and every fogged material see the same names.
    const v3 = (v) => `vec3(${v.x.toFixed(4)}, ${v.y.toFixed(4)}, ${v.z.toFixed(4)})`;
    const rgb = (hex) => { const c = new THREE.Color(hex); return v3({ x: c.r, y: c.g, z: c.b }); };
    const SUN_DIR = new THREE.Vector3(-0.6, 0.12, -0.8).normalize(); // also aims the DirectionalLight
    const SKY_GLSL = `const vec3 HORIZON = ${rgb("#f2a65a")}; const vec3 ZENITH = ${rgb("#2b3a67")};
      const vec3 SUN_GLOW = ${rgb("#ffd29a")}; const vec3 SUN = ${v3(SUN_DIR)};
      vec3 sky(vec3 d){ float s = max(dot(d, SUN), 0.0);
      return mix(HORIZON, ZENITH, smoothstep(0.0, 0.6, d.y)) + SUN_GLOW * pow(s, 8.0) * 0.35; }`;
    THREE.ShaderChunk.fog_pars_vertex = "#ifdef USE_FOG\n varying float vFogDepth; varying vec3 vFogWP;\n#endif";
    THREE.ShaderChunk.fog_vertex = `#ifdef USE_FOG
      vFogDepth = -mvPosition.z; vec4 fp = vec4(transformed, 1.0);
      #ifdef USE_INSTANCING
        fp = instanceMatrix * fp;
      #endif
      vFogWP = (modelMatrix * fp).xyz;
    #endif`;
    THREE.ShaderChunk.fog_pars_fragment = `#ifdef USE_FOG
      uniform vec3 fogColor; uniform float fogDensity; varying float vFogDepth; varying vec3 vFogWP; ${SKY_GLSL}
    #endif`;
    THREE.ShaderChunk.fog_fragment = `#ifdef USE_FOG
      vec3 ray = vFogWP - cameraPosition; float dist = length(ray);
      float f = clamp(1.0 - exp(-fogDensity * fogDensity * dist * dist), 0.0, 1.0);
      gl_FragColor.rgb = mix(gl_FragColor.rgb, sky(ray / dist) * fogColor, f);
    #endif`;
    scene.fog = new THREE.FogExp2(0xffffff, 0.004); // fogDensity stays the tuning knob

    The dome's fragment shader includes SKY_GLSL and returns sky(normalize(vDir)). Light the scene from that sky and a low sun; the three-js skill's "A world that looks like a place", when it is loaded, adds the sky-lit environment, near/middle/far depth and post.

  • A 2D canvas or p5 game paints the sky as one gradient between the place's horizon and zenith colours (ctx.createLinearGradient with two or three addColorStops, or p5's lerpColor line by line), and tints its far layers toward the horizon colour so they melt into the sky.

Otherwise, the world takes the look's colours. Resolve the theme tokens to concrete colours once per mount and paint every large area from them: the sky or backdrop from --background leaned toward --primary, fog from the same colour so the horizon melts into it, the light from --primary over --surface, the player and the thing to chase in --primary and --accent, guides and lane lines in --border, and text drawn on the canvas in --text-primary. A game's own materials (a voxel world's block table, a racer's track paint) keep their names and colours; the look owns everything around them.

The colours come from lib/look.js (the canvas theme colours above): readLook(host) gives backdrop, surface, lead, accent, ink and line as opaque hex, and watchLook repaints on a restyle.

Read the look inside the effect that builds the scene, and call watchLook in the same effect with its cleanup, so a restyle recolours the world in place (keep the sky, light and materials in one paint(look) it runs at mount and on every change):

jsconst look = readLook(containerRef.current);
const sky = new THREE.Color(look.backdrop).lerp(new THREE.Color(look.lead), 0.2);
scene.background = sky;
scene.fog = new THREE.Fog(sky, 40, 120);
scene.add(new THREE.HemisphereLight(look.lead, look.surface, 0.9));
const sun = new THREE.DirectionalLight(look.surface, 1.4);

A day/night cycle blends between two look colours (backdrop toward lead by day, toward ink by night), so every hour of the day still belongs to the app; in a named place it blends between that place's own day and night skies.

The HUD is the kit, on the look's surfaces. Everything drawn over the world is a component from @vibes.diy/ui, so it brings the look's type, radius, border and weight with it:

  • The title sits in a Heading on a Card (or a Row on bg-surface) at full ink, so it reads over a bright sky or a dark cave alike.
  • Score and best are Metrics on a Card; a timer or lap count is one more Metric.
  • The hotbar is a Row of IconButtons on a Card: the selected slot carries tint with the active colour and aria-pressed, the rest stay variant="quiet".
  • Start, pause and game-over screens are a Card or Dialog with a Heading, one lead Button and a quiet second action.
  • Overlay text keeps the look's own foreground and muted tones at full opacity; a scrim behind it comes from bg-background or bg-surface.

The play area and its controls share one screen. Every control the player reaches for while playing — the hotbar, the joystick, Start and Pause, the tempo, the mode buttons — sits over the play area or docked right against it, so a press and its result share one glance. The play area takes the space the controls leave: the page is one full-height column (flex h-dvh max-h-240 flex-col, bottom padding var(--vibes-controls-inset, 0px)), the canvas box is flex-1 min-h-0 and paints to its own size through a ResizeObserver, and the control strip is a shrink-0 Card under it (buttons in one wrapped Row, sliders in a two-column grid), or a side panel beside it from md: up. How-to-play notes, high-score tables and settings come after the play area and its controls.

Read the first screenshot before you finish: the sky, the ground, the HUD and the title should look like they came from the app's palette and type, the way its list pages do. In a named place, the sky and ground should look like that place at that hour, under a HUD in the app's look.