Quake in 13 Kilobytes (2021)
Quake in 13 Kilobytes (2021)
🕹️ Q1K3 | js13kGames 2021
The js13kGames competition is a grueling test of efficiency, challenging developers to create a fully functional game within a strict limit of 13 kilobytes (zipped). In 2021, the project Q1K3 attempted something seemingly impossible: recreating the essence of a 3D first-person shooter—inspired by Quake—within that minuscule footprint.
🛠️ The Engineering Challenge
Fitting a 3D engine into 13,312 bytes requires more than just minification; it requires a fundamental rethink of how game assets and logic are handled. The developer had to move away from traditional asset loading and toward procedural generation.
"The goal wasn't to port the actual Quake engine, but to evoke the feeling of 90s 3D gaming while fighting a war against every single byte of the budget."
Development Roadmap
- Implement basic 3D projection math.
- Create a procedural map generator.
- Develop a lightweight rasterizer.
- Optimize collision detection.
-
Include high-resolution texturesReplaced with procedural noise.
📐 The Technical Architecture
To achieve a 3D effect without the overhead of massive libraries like Three.js, Q1K3 relies on a custom rendering pipeline.
The Rendering Pipeline
The Mathematics of Projection
The engine transforms 3D world coordinates into 2D screen coordinates using a basic perspective projection formula:
Where represents the focal length of the virtual camera. This ensures that objects further away (larger ) appear smaller on the screen.
📦 Optimization Strategies
The project utilizes several "tricks" to keep the file size under the limit:
| Technique | Description | Impact |
|---|---|---|
| Minification | Using tools like Terser to strip whitespace and shorten variables. | High |
| Proceduralism | Generating textures and levels via algorithms instead of files. | Critical |
| Typed Arrays | Using Uint8Array for efficient memory management. | Medium |
| Brotli/Gzip | Leveraging heavy compression for the final delivery. | High |
Example: Asset Compression
Instead of storing a .png for a wall, the engine uses a small function to generate a "stony" texture on the fly:
function generateWallTexture() {
const canvas = document.createElement('canvas');
// ... procedural noise logic ...
return canvas.getContext('2d').getImageData(0, 0, 64, 64);
}
🎮 Gameplay and Experience
Despite the constraints, Q1K3 delivers a surprisingly cohesive experience. The player navigates a claustrophobic, industrial environment that mirrors the Gothic architecture of the original Quake.
Key Features include:
- Fluid Movement: Standard WASD controls with a simulated "bob" to mimic walking.
- Combat: A basic weapon system that utilizes
Math.random()for spread. - Atmosphere: A limited color palette to simulate the dark, moody lighting of the 1996 classic.
🏁 Final Verdict
Q1K3 stands as a testament to the power of creative constraint. By stripping away the bloat of modern game development and returning to the raw mathematics of the 90s, the project proves that immersion is not a product of file size, but of clever engineering.