HTML & CSS
Article
By Craig Buckler

JavaScript Doom

By Craig Buckler

Please forgive the blatant link-baiting title. JavaScript is fine. The world’s most-used programming language has a secure future — especially now id Software’s Doom has been converted to run in a browser!

If you’ve been overcome by euphoria, stop reading further and click the link:
developer.mozilla.org/demos/detail/doom-on-the-web/

The game is available from Mozilla’s Demo Studio; a resource which showcases HTML5, CSS3, and JavaScript technologies in Firefox and other browsers.

note: Where’s it gone?

The minute this post appeared, Mozilla pulled the Doom demo. I’m not sure why and it may only be temporary — I suspect it was overloading their servers. A video of JavaScript Doom can be viewed on YouTube while we’re waiting for it to return.

I’m conscious that SitePoint attracts readers who are far younger than me. If you’ve never heard of Doom, it’s a first-person shooting game which was released for the PC in 1993. While it wasn’t the first FPS — id Software’s Wolfenstein 3D can claim that crown — Doom revolutionized the genre. It’s pioneering 3D graphics, multi-player gaming, and graphic chainsaw-wielding violence was the inspiration for many of today’s blockbuster titles.

By modern standards, Doom is showing its age. It has antiquated blocky VGA graphics, 2D maps (walkways cannot pass over another) and limited control (no jumping or vertical aiming). But the game play remains astounding and Doom has been converted for a range of consoles and handheld devices. Now it’s been ported to JavaScript and can be played in a browser without plug-ins.

Unfortunately, JavaScript Doom is agonizingly slow in Chrome and won’t run in IE. Some versions of Safari are reported to work, but that wasn’t my experience in version 5.0.5. However, it works well on Firefox 4 and Opera; a mid-range PC should achieve 20-30 frames per second — probably better than the old 486 I used to play Doom back in 1993! There are a few graphical glitches but it’s playable.

Amazingly, the game was compiled from C to JavaScript using Emscripten and Clang then optimized with Google’s Closure Compiler. Video output is rendered on a standard HTML5 canvas element. Sound is handled using Mozilla’s non-standard Audio Data API but the effects are so nasty you won’t want them! If you’re interested, the source can be downloaded although the JavaScript is minified and unreadable.

--ADVERTISEMENT--

If You Think That’s Impressive…

Fabrice Bellard has developed an x86 PC emulator in JavaScript. For fun.

It runs in all the latest browsers so he installed the 2.6.20 Linux kernel and released browser-based emulator. Yes, it’s running Linux in a web page.

The demo is limited to terminal output rendered in an HTML table but the implications are astonishing. My only concern is that someone will add X11, install a browser and recursively implode the web!

Have you seen any other great examples of cutting-edge JavaScript?

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.