Javascript Super Mario

Technology

javascriptmario_20080412.jpg

CupBoy from the Nihilogic blog wrote a Javascript Super Mario engine which compresses down to just 14K. This includes all of the audio and sprite data for the little demo, which are both encoded within the single Javascript file.

The sprites are stored in custom encoded strings in a format that only allows 4 colors for each sprite but in turn only takes up around 40-60 bytes per sprite.

We also have MIDI music embedded as base64-encoded data: URI’s. No music for IE, though, and it seems all the other browsers each have different, minor problems with it, but it sort of works.

It is by no means a complete clone or anything, it’s not even an entire level and several key things are missing, such as mushrooms, Koopas and stuff. It was merely done as a sort of proof-of-concept and to see how small it could get.

Granted, you’re not going to fit an entire, completed Super Mario in 14KB, but just think about what was accomplished here. The image at the top of this post is probably about 30K. In half the size, CupBoy has a rudimentary side-scroller rendering engine, music, simplified physics and collision detection, and most of the artwork for the original’s first level.

Super Mario in 14kB Javascript
John Resig’s dissection of the game’s encoded data

Discuss this article with the rest of the community on our Discord server!
Tagged

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK