@trunking | ||
There's this guy who fit an entire game's source code onto a QR Code block. Use your PC webcam for this. Here's how he did it |
||
10
Replies
1583
Views
0 Favourites
|
@trunking | 8 April 21 | |
http://itsmattkc.com/etc/snakeqr/ The above QR code contains a complete Windows executable that will run on Windows 7 and up. It's a simple but fully playable implementation of Snake. A QR code is a data storage medium like any other, and while it's almost always used to store ASCII text, it can also be used to store binary data. As such, virtually any computer data can theoretically be stored in a QR code provided it can fit within the size limitations. A QR code comes in various standard sizes, the largest being version 40 which can store up to 2,953 bytes (roughly 2.9 KB) of binary data. The above code is not quite that large, it's only storing around 1.4 KB of data (shrunk down from 3.2 KB with Crinkler, slightly larger than the executable shown in the video because I decided to add a little more functionality). |
||
@trunking | 8 April 21 | |
How to Use Method 1: Webcam (automatic) You can treat this QR code much like a QR code in the real world by using your computer's webcam to read it (e.g. after loading this page on a phone or printing the QR code out). For this, I recommend using zbarcam. I've included a download link with everything you need: Download zbarcam Open ''Read Snake From QR.bat''. After a moment, your webcam will activate. Using either your phone screen or a print-out, hold the QR code up to the camera. Once it recognizes the code, it will close and Snake will appear, freshly read from the QR code. |
||
@trunking | 8 April 21 | |
Method 2: Webcam (manual) This method is the same as the above, however if you'd rather input the commands manually than running my script, go for it: Download zbarcam Open Command Prompt cd to the zbarcam folder. Run the following command: zbarcam --raw --oneshot -Sbinary *greater than symbol* snake.exe The arguments used are as follows: --raw - Disables any character encoding conversion. --oneshot - Stops reading and closes zbarcam after the code has been successfully read. -Sbinary - Informs zbarcam that the data in the code is binary data. Using either your phone screen or a print-out, hold the QR code up to the camera. Once it recognizes the code, it will close and an executable called ''snake.exe'' will appear in the same folder. Open ''snake.exe''. |
||
@trunking | 8 April 21 | |
Notes The version of zbarcam provided above has been patched to correctly output binary data on Windows. This project exposed a bug in zbarcam where binary data was incorrectly treated as text, inadvertently corrupting it as Windows attempted to convert LF line endings to CRLF. The fix used here has since been merged into zbar's master source code, but as of July 2020 no stable release version has included the fix yet. The version of zbarcam provided above has been compiled with DirectShow support for greater compatibility with webcam devices. In my video, I use a build that has not been compiled for DirectShow (using VfW instead) which leads to a black and white webcam feed. This build provides a feed in color. |
||
@trunking | 8 April 21 | |
HTML Version As a proof-of-concept, I wrote an implementation of Snake in JavaScript that, when minified, could also fit into the maximum QR code size which I briefly showcased in the video. Some people were interested in playing this, so it is available here. |
||
@warded | 8 April 21 | |
Sort of reminds me of Kkrieger. Sort of...
|
||
@trunking | 8 April 21 | |
@ warded - 8.04.21 - 01:53pm Sort of reminds me of Kkrieger. Sort of... Interesting 96Kb in file size.. How's that even possible? Should download it for myself |
||
@trunking | 8 April 21 | |
''The entire game uses only 97,280 bytes of disk space. In contrast, most contemporaneous first-person shooters filled one or more CDs or DVDs. According to the developers, .kkrieger itself would take up around 200 - 300 MB of space if it had been stored the conventional way. The game music and sounds are produced by a multifunctional synthesizer called V2, which is fed a continuous stream of MIDI data. The synthesizer then produces the music in real time.'' |
||
@trunking | 8 April 21 | |
Imagine if they sold QR codes to people, so they can access a game, movie or TV series. Even music albums. That would be pretty hilarious |
||
@trunking | 8 April 21 | |
You could store binary, or information, anywhere, well technically so. The phonograph is a fine example and the Jacquard Loom. As well as the automator. The calculator also operates because of binary |
||