How I built a video game gift in plain JavaScript, with no engine
2026-10-12
Most gifts are things. I wanted to build one that is a story: a short video game where the person you love is the hero, made from your own memories, ending with a letter from you. That became Memorcade. Here is how it works under the hood.
The idea in one paragraph
You add their name, their face, a few inside jokes, three moments (the night you met, a trip, your first place) and a letter. Memorcade turns that into a two-minute game. The inside jokes become billboards along the path, the moments become levels, their favorite things become collectibles, and the game ends with a photo booth strip of your photos and your letter typing itself out. They open it from a link: no app, no account.
No framework, one canvas
The whole game is plain JavaScript drawing to a single <canvas>. No engine, no framework. The build step inlines everything into one HTML file, about 350 KB gzipped.
- Load time. A gift link gets opened once, often inside Instagram's or TikTok's in-app browser, on whatever phone the person has. Every kilobyte of framework is more blank screen.
- Control. A hand-written loop makes it obvious where every millisecond goes.
The loop is a plain requestAnimationFrame with a variable timestep. The step is clamped to a tenth of a second, so a hiccup (a notification, a garbage collection) cannot teleport the player through a platform.
Rule one: never do expensive drawing every frame
The first version looked great on a laptop and stuttered on an older phone. The culprits were the usual ones: shadowBlur, ctx.filter, big gradients and text drawn every frame.
The fix was baking. Anything that does not change from frame to frame (the sky, distant hills, the gift box, glowing collectibles, the characters) is drawn once into an offscreen canvas at the device's pixel ratio, then copied with drawImage. Glows and shadows are baked into the sprite instead of being computed live. After that, a frame is mostly cheap image copies.
When a phone still cannot keep up
Baking was not enough for every phone, so the game also watches its own frame times. If the average over about three seconds drops below roughly 42 frames a second, the canvas resolution steps down. After about nine smooth seconds it steps back up, but it never climbs straight back to the level that was just too slow. One hiccup does not cost sharpness for the whole session.
Only the backing store is resized. The sprites are never re-baked, so the change is invisible apart from the picture getting slightly softer.
Fitting a whole gift into a link
A gift has text, settings and a handful of photos. It is packed into one URL-safe token: a version byte, a small JSON header for the words and settings, then typed blocks of JPEG data for the photos, all base64url encoded. Optional settings are left out when they have their default value, so old links keep working when new features are added.
On the hosted site the token is stored privately and the link is a short id, but the format is the same. That made testing easy: any gift can be replayed from its token.
The photo booth ending
With two or more photos, the game prints a photo booth strip between the finale and the letter, in one of four styles. Each style is a set of canvas operations (grain, tint, frame) applied once when the strip prints, then animated as it "develops". It can be saved to the phone as a full-size image.
Small things that made it feel like a gift
- Press the heart to start. Browsers block audio until a tap, so the gift opens on a wrapped box and a big heart button. The tap unlocks the sound and makes the opening feel like unwrapping.
- Sound is code too. The music and sound effects are synthesized in the browser with the Web Audio API, so they add almost nothing to the download.
- Open on a date. You can make it now and set it to open on, say, Christmas morning. Until then the link shows the wrapped box and a countdown.
Tests are what made this workable
Before every deploy, browser tests play the main flow on a phone-sized screen and a desktop-sized one: making a gift, opening it, playing it through and reading the letter. Separate suites cover each game style, the photo strip and the checkout. Screenshots are part of the check, because a test can pass while the page looks wrong.
What I would do differently
- Start with the cheapest phone you can find, not your laptop.
- Bake everything you can on day one.
- Test inside in-app browsers early. They have their own quirks with audio and file pickers.
The sample on the home page is free to play if you want to see it running.
How it was built: I directed and tested, and Claude (AI) wrote most of the code and helped write this post. The art and sound are drawn by code. There are no AI-generated images in the game.
Her face on the hero, your inside jokes on the signs, a photo booth strip and your letter at the end. Made in a few minutes, and sent as a link. Plays on any phone.
Free to make. $4.99 to send, or $9.99 with you and your voice at the end.
Christmas price: 40% off every gift until Nov 30, so $2.99 to send, or $5.99 with you and your voice at the end.
Start her game freeMore from the blog
- Week 1: 22 visitors, 0 sales. What I got wrong launching a gift game
- Make a personalized Christmas gift for your boyfriend
- A last minute digital Christmas gift that feels planned
- Unique gifts for couples, made from your story
- Long distance Christmas gift that opens Christmas morning
- What to get someone who has everything for Christmas
- Secret Santa gift for a coworker you barely know
- A Christmas gift kids can make for mom and dad
- Christmas gifts under $10 that do not feel cheap
- How long distance couples can share Christmas morning
- How to make a memory game gift from your own memories
- A Christmas gift for grandparents from the grandkids