Every CV I send now has a note at the top saying “Is reading this CV too boring? Try a more interactive version”, and next to it there’s a QR code that opens a rhythm game where you fight slimes on the beat to unlock my work history. Coming from the guy who made a game version of his own blog, I know, this is not exactly a plot twist.
Play it here!#
But… why?#
I’m applying for jobs, and applying for jobs means writing resumes, and writing resumes means proofreading my own background over and over again, same companies, same dates, same bullet points, until at some point I thought “damn, this is boring af”.
The last time resumes annoyed me this much I built Resume Builder, and a recruiter found the repo, asked if I knew React, and that’s how I ended up in the Netherlands. So I already have a history of solving resume problems with code, and this time I remembered my blog game and thought “what kind of game would fit nicely as a way to show my resume?”. And nothing popped up in my head. Nothing at all.
Gotinha, again#
A few days later I remembered Gotinha, the first game I ever released, the little drop of water dodging fire hydrants. I always wanted to go back and improve it, because since then I’ve grown both as a programmer and as a game developer, and Gotinha is still the game whose levels are generated by a bunch of dashes falling down the screen.
So the first draft was just Gotinha, and the further you went, the more stuff from my resume was revealed. All nice and dandy.
The original Gotinha, still dodging hydrants
The band rehearsal#
Then one day I went to a rehearsal of a friend’s band, and they were playing this very funky and catchy tune, and it reminded me of Crypt of the NecroDancer, the dungeon crawler where you can only move on the beat of the music. And then I thought, what if I made Gotinha, but with rhythm?
That was it. The name is basically because I really like the word “tempo”, since when I learn it from that Fatboy Slim song. I mean of course, tempo is also the theme of the game in a way, so it all fits together nicely.
Gotinha, but with rhythm: three lanes, a beat bar at the bottom and a slime waiting for you
Product owner mode#
Gotinha had one rule: I made everything myself, the code, the sprites, the sound effects, the music, even the shitty art. This time I wanted to see how far AI had gone, so I would act basically as the product owner and create a game from start to finish without creating anything myself, only the idea.
Only the code though. I didn’t want AI-generated music or AI-generated art, because there are plenty of free tracks and art made by real people out there. So after some research and listening to some tracks, I picked these:
- the Ninja Adventure Asset Pack by Pixel-boy and AAA, for the characters, monsters, bosses, tiles and sound effects
- the hero comes from Puny Characters by Shade, the Warrior-Blue sheet cropped down to 16x16 frames
- three tracks from the Free Rhythm Game Music Pack 2 by Tricks & Traps: Extended, T.O.E. and Drama
All of them are CC0, so credit is not mandatory, but of course, highly appreciated by these talented people, so in a credits screen in the game I have all the arts attributions and their respective links.
The only exception was the poison pool. I needed an extra tile for a hazard and the pack didn’t have one, so I used Gemini for a draft idea, then resized it in Photopea and did some retouches. That, and the logo, but more on that later.
Everything here is free to use. Thanks to the people who made it.
The tracks don’t go into the game as they come in the pack. A script cuts each one into a loop of whole bars, starting exactly on the first beat, so the song can loop forever without drifting away from the game:
const TRACKS = [
{ id: "extended", file: "5_extended.wav", bpm: 120, bars: 48 },
{ id: "toe", file: "7_t.o.e.wav", bpm: 120, bars: 48 },
{ id: "drama", file: "2_drama.wav", bpm: 86.6667, bars: 32 },
];
for (const track of TRACKS) {
// ...decode the WAV to mono, low-passed to the kick drum, at 4000 Hz
const phase = measurePhase(pcm, SAMPLE_RATE, track.bpm);
const seconds = (track.bars * BEATS_PER_BAR * 60) / track.bpm;
execFileSync("ffmpeg", [
"-v", "error", "-y", "-ss", phase.toFixed(4), "-t", seconds.toFixed(4), "-i", input,
"-c:a", "libmp3lame", "-b:a", "160k", path.join(outDir, `${track.id}.mp3`),
]);
}measurePhase finds where the first beat is, and then ffmpeg cuts exactly 48 bars (or 32 for Drama) from there. More on measurePhase in a bit, because it shows up again in the browser.
The infinite runner#
I got the Phaser 4 boilerplate with Vite and used Claude to create an infinite runner concept, with the enemies and hazards showing up as you go. Like in Gotinha, the player doesn’t really go anywhere, the dungeon comes to you, but instead of two walls there are three lanes, and every press of a button is one step.
The level generation is a lot less embarrassing than Gotinha’s dashes. The dungeon is built from small hand-made patterns, one row per step, where s is spikes, o is a poison pool and e is an enemy:
{ "id": "single-spike-center", "minTier": 0, "rows": [".s."] },
{ "id": "wall-gap-left", "minTier": 1, "rows": [".oo"] },
{ "id": "weave", "minTier": 2, "rows": ["s..", ".s.", "..s"] },
{ "id": "slalom", "minTier": 3, "rows": ["s.o", "os.", "s.o"] }Harder patterns open up at higher tiers, and the empty rows between them go from three to one. Before a pattern goes in, the generator checks that you can actually get through it, starting from every lane you could be standing in and moving at most one lane per row:
export function reachable(rows: readonly Row[], from: readonly Lane[]): Lane[] {
let lanes = new Set<Lane>(from);
for (const row of rows) {
const next = new Set<Lane>();
for (const lane of lanes) {
for (const direction of [0, -1, 1] as const) {
const target = direction === 0 ? lane : moveLane(lane, direction);
if (!isHazard(row[target])) next.add(target);
}
}
lanes = next;
if (lanes.size === 0) return [];
}
return [...lanes].sort() as Lane[];
}So a run can always be survived, as long as you keep the beat. Monsters are optional, you can walk around them, except for the gates. Every 40 rows the generator puts a breather row and then a monster across all three lanes, and there’s no way around it:
if (gates && produced >= nextGate) {
// A breath, then the gate. Whatever lane the player is in, they fight, and they can step anywhere during it.
push(decorate(EMPTY));
push(GATE);
lanes = [0, 1, 2];
nextGate = produced + gates.every;
return;
}The first gate comes at row 12, so every run meets a monster (and a piece of my resume) within seconds, and the game literally shows “NO WAY AROUND!” on the screen when it happens.
A poison pool, some coins and a slime up ahead
Fighting on the beat#
Walking into a monster starts a fight, and the buttons keep the same meaning: left, right and stay. Every press on the beat hits the monster, and the monster announces red lanes that you have to step out of before they slam. The monsters are strings too, each character is one step of their attack, and p aims at whatever lane you’re standing in:
{ "id": "giant-slime", "sprite": "giant-slime", "boss": true, "hp": 24, "damage": 2, "tier": 1,
"phases": [
{ "fromHpFraction": 1, "cycles": ["..p.", "..s."] },
{ "fromHpFraction": 0.5, "cycles": [".p.p", ".l..r.", "pp.."] }
] }A perfect press does two damage and a good one does one, and when a hit takes a boss into its next phase, its pattern starts over and the strikes already on their way get called off (and the screen shows “RAGE!”):
export const HIT_DAMAGE: Record<"perfect" | "good", number> = { perfect: 2, good: 1 };
export function hitEnemy(battle: Battle, judgement: "perfect" | "good"): HitResult {
const damage = Math.min(HIT_DAMAGE[judgement], battle.enemyHp);
const enemyHp = battle.enemyHp - damage;
if (enemyHp <= 0) return { battle: { ...battle, enemyHp: 0, strikes: [] }, damage, defeated: true, enraged: false };
const phase = phaseIndex(battle.enemy, enemyHp);
if (phase !== battle.phase) return { battle: { ...battle, enemyHp, phase, cursor: 0, strikes: [] }, damage, defeated: false, enraged: true };
return { battle: { ...battle, enemyHp }, damage, defeated: false, enraged: false };
}A boss shows up after six regular fights. The Giant Slime has 24 HP and changes its pattern when it’s down to half, and the Demon Cyclop has 32 HP and three phases.
The Demon Cyclop, a red lane about to slam, and the poison pool on the side
The screenshots and the video in this post were recorded from the Playwright bot that the browser tests use, which plays the real game against the real audio clock, pressing just after every beat. It beat the Demon Cyclop without losing a single heart.
The part I didn’t trust Claude with#
The one thing I didn’t think Claude would be good at was matching the gameplay tempo to the song. A rhythm game is all about the feeling of the press landing exactly when the music hits, so I did this part manually for the default song, Extended, especially because I really wanted to nail the feeling of the game.
And of course Extended was the annoying one. It’s 120 BPM, but its kick doesn’t hit on every beat, it goes “DUM DUM, rest”, so pressing on every beat felt like every other press was falling on nothing. My first try was to play it at 60 BPM in bars of two beats, and 20 minutes later I threw that away and gave it a groove instead, a cycle of two beats with one step on the first beat and another one a dotted eighth later:
{ "id": "extended", "name": "Extended", "file": "extended.mp3", "bpm": 120, "beatsPerBar": 4, "stepEvery": 1,
"groove": { "beats": 2, "steps": [0, 0.75] }, "phaseHint": 0.98, "loopBars": 47, "artist": "Tricks & Traps" }The game counts in steps, not in beats, so with a groove the step position is just a bit more math. Inside each cycle it finds which step you’re in and how far into it, and everything else (the runner, the fights, the countdown) keeps working in steps without knowing the track is weird:
export function stepPosition(songTime: number, track: Track, calibrationSeconds = 0): number {
const beat = beatPosition(songTime, track, calibrationSeconds);
const { beats, steps } = grooveOf(track);
if (steps.length === 1) return beat / beats;
const cycle = Math.floor(beat / beats);
const within = beat - cycle * beats;
let index = steps.length - 1;
while (index > 0 && steps[index] > within) index--;
const end = index + 1 < steps.length ? steps[index + 1] : beats;
return cycle * steps.length + index + (within - steps[index]) / (end - steps[index]);
}The build also refuses a groove where two steps are closer than 0.36 s, so the “good” windows of two steps never overlap, not even with Relaxed timing on.
Keeping the beat#
The song is the clock. Time is never summed from frame deltas, it’s read off the Web Audio clock, and not just currentTime, which is the sample being rendered right now, but getOutputTimestamp(), which is the sound coming out of the speakers right now:
songTime() {
if (!(context && source)) return silent.songTime();
// Frozen while suspended: the output timestamp would keep extrapolating.
if (context.state !== "running") return lastSongTime;
lastSongTime = Math.max(lastSongTime, heardAt(performance.now()) - startedAt, 0);
return lastSongTime;
},The screen and the input read the same clock, so a press on the beat you see is a press on the beat you hear. And if Web Audio doesn’t work at all, it falls back to a silent clock and the game is still playable with the beat bar on the screen.
A press is graded by how far it is from the nearest step:
/** The starting windows: ±60 ms is perfect, ±120 ms is good. */
export const DEFAULT_WINDOWS: Windows = { perfectMs: 60, goodMs: 120 };
/** The assist for touch screens and slow displays: every window 50% wider. */
export const RELAXED_FACTOR = 1.5;
export function judge(offsetMs: number, windows: Windows): Judgement {
const distance = Math.abs(offsetMs);
if (distance <= windows.perfectMs) return "perfect";
if (distance <= windows.goodMs) return "good";
return "miss";
}In the dungeon a press moves you at once, but a step without a press only counts as missed when its late “good” window is over, so a press that’s a little late still counts:
/** A step with no press is resolved once its late Good window is over: this song time. */
const graceOver = (step: number) => timeOfStep(step, track, calibration) + windows.goodMs / 1000;There’s also a “Relaxed timing” option that makes both windows 50% wider, and you can calibrate your own offset in the settings by tapping along.
The last piece is measurePhase, the same one from the script that cuts the loops. The game runs it again in the browser every time it loads a song, because MP3 decoders add different amounts of silence at the start of the file, and without it every press would be off by however much silence your browser decided to add. It builds an envelope of how much louder the low end gets every millisecond, then tries every possible offset inside one beat and adds up the kicks that land on that offset, and on every beat after it. The offset with the most kick wins:
export function measurePhase(samples: ArrayLike<number>, sampleRate: number, bpm: number): number {
const { onsets, rate } = onsetEnvelope(samples, sampleRate);
const period = (60 / bpm) * rate;
const candidates = Math.max(1, Math.floor(period));
let best = 0;
let bestScore = -1;
for (let candidate = 0; candidate < candidates; candidate++) {
let score = 0;
for (let at = candidate; at < onsets.length; at += period) score += onsets[Math.round(at)] ?? 0;
if (score > bestScore) {
bestScore = score;
best = candidate;
}
}
return best / rate;
}The catch is that the body of a kick peaks tens of milliseconds after its click, so a detector that only listens to the low end reads the beat a little late. That’s why every track also has a phaseHint, the real first beat checked against the hi-hats, and the browser only uses its own measurement to correct for whatever the decoder shifted.
Two more songs#
After finishing it for Extended, I asked Claude to do it for T.O.E. and Drama, and it actually did a good job.
T.O.E. was the easy one, a straight 120 BPM with the first beat right at the start of the file. Drama was first read as 130 BPM, but the pulse you actually tap along to is the hi-hats, and they tick at 86.67, two thirds of that, so the loop went from 48 bars to 32 for the same 88 seconds of music.
And later I made T.O.E. the default song instead of Extended, so the one song I didn’t trust Claude with is now the one you only hear if you go looking for it.
The resume part#
Defeating monsters unlocks memories in the Career Log, 48 of them, from two weeks cleaning up restaurant data in Dreamweaver at my first job to Studocu and Musclog. And since this is a resume, the game can’t make stuff up. The log file only says which piece of my portfolio each memory shows, plus a title:
{"id": "studocu-cookies", "kind": "work", "source": "studocu", "highlight": 2, "match": "Made Laravel and Next.js read and write", "title": {"en": "One session, two frameworks", "pt-br": "Uma sessão, dois frameworks"}, "major": true}The company, dates, tags, link and the text itself come from the same portfolio.json as my portfolio page, in the page’s language, so the game can’t say anything the portfolio doesn’t. match is the start of the English text, and if I edit or reorder a line in the portfolio, the build fails instead of shipping a memory with a title that doesn’t fit anymore:
else if (locale === "en" && !found.description.startsWith(ref.match)) {
problems.push(`${where}: the portfolio text no longer starts with "${ref.match}" (it starts with "${found.description.slice(0, 40)}")`);
}Bosses drop the major ones first. You also collect coins on the way, and coins buy memories in the Memory shop, 20 coins each, which is about what a decent run brings home. You pick a part of the career (work, projects or recognition) and get a random locked memory from it, so a purchase is still a surprise and fighting is still the main way in:
export const MEMORY_PRICE = 20;
export function buyMemory(data: SaveData, entries: readonly ShopEntry[], category: CareerKind, rng: Rng): { data: SaveData; id: string } | null {
if (data.wallet < MEMORY_PRICE) return null;
const have = new Set(data.found);
const pool = entries.filter((entry) => entry.category === category && !have.has(entry.id));
if (pool.length === 0) return null;
const id = rng.pick(pool).id;
return { data: { ...data, wallet: data.wallet - MEMORY_PRICE, found: [...data.found, id] }, id };
}It’s a static page like the rest of this site, so there’s no backend, and your progress is saved in localStorage.
Memory found mid-fight, and the Career Log after the run: 5 of 48
And for the recruiter who really doesn’t want to play, the first screen says “Reading a bunch of text is indeed very boring.” and has a button that says “Nah, take me to your portfolio”.
The first thing a new player sees, after the logo
Splash screen#
My games needed a splash screen, and a splash screen needs a logo, and I don’t have one, so I asked Gemini for something called GNAF, short for Games Nobody Asked For (I just needed it to look serious). What came back was a PNG, and the problem with a Gemini PNG is that it’s a PNG: blurry edges, a cyan and a lime that don’t exist anywhere else on my site, and zero chance of staying sharp on a 4K monitor. I cropped it down to 1198x603, just the letters and the tagline, and that crop is what Claude traced.
Claude traced it with potrace (the potracer Python package), on a copy scaled up 3x
The trace turned it into an SVG: the G and the tagline came out as curves, and the N, the A and the F came out as straight-edged polygons, because they are straight-edged polygons. I ended up with four paths in total, one per color, using fill-rule="evenodd" so the holes in the G and the A stay holes. Then I swapped the colors for the palette I already use (#8c9eff indigo, #eeff41 lime, #f5f5f5 white, on a #212121 background) so the logo matches the rest of the site instead of looking like it came from somewhere else, which it did. The whole thing is 18KB, it scales to whatever size I want, and you can read the final version at gnaf-logo.svg, or just open one of my games, because it’s the first thing you see (for about 2.5 seconds now, since it was on screen so briefly that you could barely read it).
The traced version, with the colors swapped to match the site
Conclusion#
From there it was just adjusting some things here and there, and in the git history “here and there” means poison pools, a new walking animation, playing the whole thing with the keyboard and the splash screen, all on the same day.
I wanted to see how far AI had gone, and it went far enough that the one part I didn’t trust it with, I handed over after the first song anyway. Meanwhile, the original Gotinha is not even on Google Play anymore, because I had to update it and I didn’t.
The code is closed for now, which is why this post has so much of it. You can play My body is a Tempo here.