How a 3D multiplayer game fits in under 1 MB
Published · Updated
Legends of Eldruva is a 3D multiplayer game whose client, server and manifest add up to 340 KB. The desktop edition of the same project, built on a game engine with imported art, is about 168 MB, roughly 482 times larger. The difference comes from one decision: replace every asset with code that generates it.
Play now in your browser Play with friends
Where the megabytes went
| Package | Size |
|---|---|
| Engine-based desktop build: engine, packed data and game server | about 168 MB |
| Micro edition client: one HTML file | 328 KB |
| Micro edition server | 11961 bytes |
| Micro edition, everything | 340 KB |
Most of the large build is the engine itself and imported art: models, textures and their sources. The micro edition carries none of it.
Replacing assets with code
- Terrain and materials in the shader. Sand, clay, rock and ores are colored and textured by the WebGL2 fragment shader from noise functions. There are no texture files.
- Models assembled at startup. Characters, trees, buildings and skeletons are built from boxes and simple shapes in code when the game starts.
- Icons rendered by the game. Inventory icons are drawn by the same renderer into small images.
- Synthesized sound. Every sound is generated with the Web Audio API.
- Interface in the DOM. The HUD is HTML and CSS, not textures.
One set of rules for client and server
The game logic, world generation and simulation are plain JavaScript files shared by the browser and the Node.js server. Every action goes to the server, which applies it with the same rules and sends it to everyone in order; each client replays it on its own copy of the world. Because the rules are deterministic, every copy stays identical without sending the world state. Every 40 commands a summary of the state is compared, and a client that drifted reloads the world.
Build
A small script concatenates the source files into one HTML page and one server module, strips comments, and fails the build if the total passes 1 MB. There are no dependencies: the server implements HTTP and WebSocket itself on Node.js.
What it costs
- Generated art has a recognizable, blocky look, and some interface frames are still missing ornaments.
- Every client has the full world state, so a curious player can find where fossils are hidden by inspecting the browser. For a group of friends playing together, simplicity won.
Questions about this
Does it use a game engine?
No. It is plain JavaScript and WebGL2.
Does it use any libraries?
No. Client and server have no dependencies.