Byte-sized: Bite-sized JavaScript platformer Bouncing Beholder is astonishingly small, taking up just 1,024 bytes – roughly a thousand times less data than a single promotional screenshot for a flagship video game. Despite its minuscule size, it includes all the essential elements of a classic platformer.
Games keep growing larger every year, but a group of developers is pushing back against the trend. We’ve already seen astonishingly small versions of Tetris, Snake, and Doom, but their tiny file sizes often come with trade-offs like clunky controls, limited animation, and a lack of color.
Bouncing Beholder, however, is different. Despite its minuscule size, it delivers a full-fledged side-scrolling adventure with smooth animations, responsive physics, randomly generated terrain, collectibles, and hazards to avoid.
Players control a perpetually bouncing eyeball using the arrow keys, navigating a deceptively inviting landscape filled with dangers. The goal is to collect as many coins as possible while avoiding hazards. And when you inevitably lose, the randomized level design ensures that every replay feels fresh.
The game was written by Marijn Haverbeke, who originally created it for the JS1K coding competition way back in 2010. It was recently rediscovered thanks in part to its strict file size limit.
Haverbeke achieved this astonishing level of optimization through a series of clever coding tricks. These include abbreviating long variable names and representing game states using mathematical formulas instead of storing data directly.
For example, coin locations aren’t pre-defined but instead follow a simple rule: coins appear on any platform whose height is divisible by six. Collecting one slightly lowers the platform’s height, effectively removing the coin.
Haverbeke also devised a system to automatically shorten lengthy method names from the HTML5 Canvas API used to render graphics. Instead of writing canvas.quadraticCurveTo(), he can simply use qt(). When your entire game fits within a single kilobyte, every character matters.
In fact, the code is so tightly packed that modern compression tools like Google’s Closure Compiler actually increased the file size rather than reducing it.
As Haverbeke humorously notes in his blog: “In terms of productivity, this is an awful way of coding. But it certainly is fun. Not to mention that it gives me an excuse to use every kind of weird hack I can think of.”
The full game code can be found over on Haverbeke’s blog.
Source link