Can you fit a whole game into a QR code?

Channel:MattKC · Length:20:03 · Published:2020-07-31 · Views:9003560

Watch on YouTube

Summary

MattKC fits a playable Snake game into a QR code by writing tiny x86 machine code and patching the ZBar scanner so it can run the decoded data.

Why HN recommends it

HN admires it as a creative hack and cites it as the inspiration for later tiny-game and QR-code projects.

I admire this type of content where the creator take some concepts we [all] use and understand — HN, 2022

Software performance & optimization · Security & hacking · Demoscene & retrocomputing

Subtitles (excerpt)

Yes! At least in theory. And I'm not talking about just putting the URL to some online game in; you can obviously do that. I mean 100% of the game's code stored entirely on one of these. As surprising as it is to say, there theoretically is absolutely no reason you couldn't. A QR code is technically just a storage medium like any other. It's just as legitimate as a floppy disk, CD, or even hard drive. It doesn't store much data, but it is data nonetheless. Keep in mind the bar for data storage is actually pretty low. You could also manually write out binary zeros and ones or hex bytes by hand. It's not very efficient, but technically you've stored computer data. And while a QR code is most commonly used to store ASCII text, it can actually be made to store binary data as well. Which pretty much means anything you can store on a computer, you can store on a QR code - provided that it fits inside the size limitations. How limited are we? Well QR codes come in various standardized sizes, but the largest is version 40 which gives us an ABSOLUTELY LEVIATHAN 2,953... ...bytes. Yeah, slightly less than 3 KB. It's not much. If you're curious just how not much, this sound from Windows 10... [short click] A sound that lasts for 1/15th of a second, this sound...

On Hacker News

I admire this type of content where the creator take some concepts we [all] use and understand then combine them in a specific, but a new way, add some tweaks to get some never-seen results. Here is another experience that, as a Windows developer, blows my mind for a while. [VIDEO] — redbell, 2022-07
Using all the browser functionality feels like cheating. There is a good YouTube video, where a person made a snake game that fits inside a QR Code (albeit a larger version that we're used to, which can hold up to 2953 bytes). You can check it out here: [VIDEO] Quite an interesting watch. — fath0m, 2020-11
Really cool project! TIL about 'data:' URLs—while I was familiar with the 'data:' URI scheme and had used it before, I didn’t realize it could be used as a full URL. Funny enough, I had been thinking about building something similar that fits entirely within a QR code, but I held off because I mistakenly thought it would require an HTTP(s) link. I was heavily inspired by this work: Can you fit a … — redbell, 2025-04
QR codes have various encoding modes: numeric, alphanumeric, 8 bit and kanji. The most common is alphanumeric encoding and the densest is 8 bit encoding which just stores binary data. The QR code standards seem to be a little ambiguous on the meaning and purpose of the 8 bit encoding. I got the impression they added it to support alternative character encodings. Still, it's a mode that "represent… — matheusmoreira, 2025-04
In a similar vein, there's Can you fit a whole game into a QR code? by MattKC, which is limited to about 3 kilobytes (2,953 bytes) [VIDEO] — askiiart, 2024-01

Related videos