The Backdooms: Play DOOM Instantly via QR Code
The Backdooms is an innovative project that allows gamers to play a version of the 1993 classic DOOM directly through a QR code. This remarkable game is not just a nostalgic throwback; it showcases an inventive method of hosting lightweight web applications, enabling players to dive into a world of adventure without the need for downloads or installations.
Project Overview
The Backdooms is a compressed, self-extracting HTML game inspired by the original DOOM and the intriguing concept of The Backrooms. The entire game can be launched and played in a web browser, providing an instant gaming experience just by scanning a QR code. Originally conceived as a week-long study, this project has evolved into a significant demonstration of how to push the limits of QR code storage and compression.
For those who want to try a slightly less compressed version of the game, you can access it here.
Notable Features
The Backdooms is packed with features that enhance the gameplay experience:
- Fully Offline: Once you scan the QR code, no internet connection is required for gameplay. The URL contains the entire code necessary to enjoy the game.
- Extreme Compression: The game employs a blend of Zlib compression alongside Gzip Decompression stream and base64 encoding to achieve a highly compact final product.
- Self-Extracting Webpage: Utilizing the DecompressionStream API, the game compresses and executes itself dynamically within your browser.
- Mobile Compatibility: This game works seamlessly on modern mobile browsers that support the Decompressionstream APIs, including Edge, Yandex, and Opera.
Installation and Dependencies
Technically, the only requirement is a modern web browser. However, for those delving into the intricacies of generating a QR code for a game that is approximately 2.5kb, here are the prerequisites:
- Python 3.7 or higher
- qrcode library for generating QR codes
- pillow library for handling QR code images
To install the necessary dependencies, simply run the following command:
pip install qrcode[pil]
How to Use The Backdooms
Heres a quick guide to get you started:
- Convert Your Game to a QR Code:
Execute the script with this command:
python3 QRGEN.py < your-game.html > < output-qrcode.png >
- Scan the QR Code:
Use a smartphone or QR scanner to access the game directly in your web browser. - Play Instantly:
Jump into the action with The Backdooms without needing any downloads or installations!
Technical Breakdown
Understanding the compression workflow is essential for grasping how this project works. The following steps detail the compressing process:
- Read Input HTML: The process kicks off by reading the HTML content from a specified file or input source.
- Zlib Compression + GZip Decompression: The HTML undergoes compression using Zlib, employing GZips Decompressionstream for optimal results.
- Base64 Encoding: The compressed data is encoded in Base64, ensuring it remains text-based and can be safely embedded within an HTML file.
- Embedding in HTML Wrapper: A JavaScript-based self-extracting HTML wrapper is created, which automatically decompresses content when accessed in a browser.
- Data URI Conversion: The entire HTML content is converted into a
data:text/html;base64,...
format, enabling easy storage and sharing.
QR Code Generation Logic
The system optimizes the QR code generation process by first attempting to create the smallest version possible. If the required version exceeds 40the upper limit for QR codesit defaults to version 40 while prioritizing data capacity.
In cases where the data exceeds capacity, the system will return an error message, ensuring clarity about the encoding limitations.
Understanding the Development Journey
If you're interested in the challenges faced during development, you can read about the entire journey on my blog MindDump.
License Information
The Backdooms is released under the MIT License, allowing for free use, modification, and sharing. It would bring immense joy to see others creating QR games or even improved versions of DOOM embedded within QR codes, as there are limited resources available for such projects.
Acknowledgments
Special thanks to id Software for developing the original DOOM, to matttkc for inspiring this idea five years ago, and to Toby Fox for the captivating music in Undertale, which features an 8-bit version of the iconic track Bonetrousle in the game's GitHub hosted version.
Developed by Kuber Mehta.