HomeAboutProjectsRadarUniverseSkillsAchievementsContact
🌙
Home

I made a game for my girlfriend for when she’s annoyed at me

November 2026

three.jsWeb AudioGamedev
Punch Bub: a tiny 3D copy of our apartment with a blocky me in the middle

I made this game for my girlfriend for when she's annoyed at me.

It's a tiny 3D copy of our apartment in Vancouver, with a blocky version of me standing on our zebra rug. She jokes about wanting to beat me up when I'm being annoying, so now she can. I was away for a few weeks when I built it, and long distance makes small arguments feel bigger.

Ten seconds of gameplay on a phone: a punch, a chappal and a hug

How it plays

  • Punch: tap me and I go flying, bounce off the floor and get back up. Hold to wind up a harder punch that sends me further and gets a different reaction.
  • Chappal: throw a slipper at me. The classic desi move.
  • Pillow: a softer hit for when she's only a little annoyed.
  • Hug: hearts float up, my eyes turn into hearts and I say something sweet.

Every few hits I drop a heart. Each one unlocks a reason I love her, and she can reread them all in her collection. She can also tap things in the room, like the couch, the TV or the rug, and I walk over and say something about it.

It runs in the browser, it's made for her phone, and it's one HTML file plus three.js. The rest of this post is how it's built.

The stack

  • three.js (r128) for rendering. No bundler and no framework: one <script> tag and an inline script.
  • Canvas 2D for every texture. There are no image files in the game.
  • Web Audio for every sound. There are no audio files either.
  • Pointer Events and a raycaster for input.
  • localStorage for progress.
  • Vercel for hosting, as a static folder.
  • Playwright with headless Chromium for testing, including WebGL in software.

The hosted page is about 64 KB of HTML. With three.js and two self-hosted fonts it comes to roughly 730 KB before compression, and most of that is three.js.

The room

Everything in the scene is a BoxGeometry with a Lambert material: walls, couch, plant shelf, the round dining table, the gallery wall behind the couch. I built it from photos of our place, so the furniture sits roughly where it really is. Getting the furniture in the right spots took me a few tries.

The camera is a perspective camera with a narrow 30° field of view, which reads as almost isometric. The tricky part was making the whole room fit on a portrait phone and a landscape laptop. fit() works out the horizontal field of view from the aspect ratio and backs the camera off until a bounding sphere around the room fits in both directions:

function fit() {
  const w = canvas.clientWidth, h = canvas.clientHeight;
  renderer.setSize(w, h, false);
  camera.aspect = w / h;
  const v = THREE.MathUtils.degToRad(camera.fov);
  const hf = 2 * Math.atan(Math.tan(v / 2) * camera.aspect);
  const R = h > w ? 5.3 : 6.3;
  camDist = Math.max(R / Math.sin(hf / 2), R / Math.sin((v * (h > w ? 0.6 : 0.78)) / 2));
  camera.updateProjectionMatrix();
}

Pixel art without image files

Faces, the zebra rug, the city outside the window, the TV and the tiny portraits on the gallery wall are all drawn at runtime on a small canvas and used as a texture with nearest-neighbour filtering:

function pixelTex(n, draw) {
  const cv = document.createElement('canvas'); cv.width = cv.height = n * 4;
  const g = cv.getContext('2d');
  draw((x, y, c, w, h) => { g.fillStyle = c; g.fillRect(x * 4, y * 4, (w || 1) * 4, (h || 1) * 4); }, n);
  const t = new THREE.CanvasTexture(cv);
  t.magFilter = THREE.NearestFilter; t.minFilter = THREE.NearestFilter; t.generateMipmaps = false;
  return t;
}

My face is a 16×16 grid with five expressions (smiling, bracing, hit, dizzy, heart eyes). Swapping the material's map is all it takes to change expression. The zebra rug is a single sine-wave formula, and the window is a hand-placed skyline.

Making it feel good to hit me

There's no physics engine. Blocky me is a small state machine: standing, walking, flying, lying on the floor, getting up. A hit pushes me away from the camera with a random spin, and then gravity, bouncing off the floor, and bumping into the walls and the kitchen counter do the rest. I squash on impact, my arms and legs flail in the air, the camera shakes a little, and there's a thud.

Each weapon feels different. The glove is quick and direct. The chappal arcs through the air, spinning, and bounces off me onto the floor. The pillow barely moves me. A hug makes me hop, my face switches to heart eyes and hearts float up.

Holding down on me winds up the punch. The longer she holds, the harder it hits, and a full-power punch sends me across the room with a different line.

Tapping uses three.js's Raycaster. I'm a small target on a phone, so I carry an invisible, bigger box for her taps to hit.

Speech bubbles and hearts are plain HTML on top of the canvas. Every frame, I work out where the point above my head lands on screen and move the bubble there, so the text stays sharp.

Sound with no audio files

Every sound is synthesized with Web Audio. A punch is a sine wave sweeping down in pitch with a short burst of noise on top:

function tone(f1, f2, dur, vol, type) {
  const a = audio(); if (!a) return;
  const t = a.currentTime, o = a.createOscillator(), g = a.createGain();
  o.type = type || 'sine';
  o.frequency.setValueAtTime(f1, t); o.frequency.exponentialRampToValueAtTime(Math.max(20, f2), t + dur);
  g.gain.setValueAtTime(vol, t); g.gain.exponentialRampToValueAtTime(0.001, t + dur);
  o.connect(g); g.connect(a.destination); o.start(t); o.stop(t + dur + 0.02);
}
// thud: tone(170 + 60 * power, 45, 0.18, ...) plus noise(0.07, ...)

The audio context starts on the first tap, since browsers block sound until the user interacts. On Android a hit also gives a short vibration.

Keeping the reasons real

The reasons are the point of the whole thing. Every line in the game lives in one content.json, and each reason is tagged with where it came from: something we actually said, my own notes, a photo, or a placeholder I still needed to replace. That made it easy to find and rewrite anything that sounded generic.

A small build script bakes the content into the HTML and writes a readable CONTENT.md for review. I also had a private editor for changing, removing and adding lines without touching code. The public build strips the editor, the source tags and a debug hook, and the build fails if any of them are still there.

Getting it onto her home screen

The game ships with a web manifest and an Apple touch icon, so "Add to Home Screen" gives it its own icon and opens it full screen without browser chrome.

It's hosted on Vercel as a separate project pointed at the built folder of a monorepo. Two things caught me out:

  1. Without its own vercel.json, the subfolder project picked up the repo root's config and tried to run the other app's build (tsx: command not found).
  2. A header rule with a nested group in its source pattern is invalid, and the automatic deployment for that push never showed up. Deploying through the API surfaced the real error.

The link is unlisted rather than public. The page sends a same-origin Content Security Policy, blocks framing, sets no-referrer, and tells search engines to stay away. Fonts are self-hosted, so the page makes no third-party requests at all.

Testing WebGL without a GPU

I tested in headless Chromium with SwiftShader (software WebGL) at phone and laptop sizes, with touch on the phone and a mouse on the laptop. The checks covered taps registering, reasons dropping, no horizontal scrolling, no CSP violations and no outside requests.

Software rendering is slow, so recording gameplay in real time gave a choppy video. For the clip in this post I replaced performance.now, requestAnimationFrame and setTimeout with a fake clock and paused CSS animations, then stepped the game one frame at a time and screenshotted each frame. That gave a smooth 30 fps clip even on a slow machine, and ffmpeg turned the frames into the MP4 and GIF.

Built with Claude Code

I built this with Claude Code. It wrote most of the code, the tests and the capture script. I decided what the game should be, got the apartment right, and picked and edited the reasons.

What I'd do next

  • A passcode, so the reasons stay private even if the link gets out.
  • More reasons. She has 76 so far.
  • Real photos in a couple of the gallery frames.
See the project page