JavaScript Doom

    Craig Buckler
    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: 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.

    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?

    Frequently Asked Questions (FAQs) about JavaScript DOOM

    What is JavaScript DOOM?

    JavaScript DOOM is a version of the classic video game DOOM that has been rewritten to run in a web browser using JavaScript. This allows the game to be played on any device with a web browser, without the need for any additional software or plugins. The game retains all the original features, including the graphics, sound effects, and gameplay mechanics, providing a nostalgic gaming experience for fans of the original DOOM.

    How does JavaScript DOOM work?

    JavaScript DOOM works by using a combination of HTML5 and JavaScript to recreate the original DOOM game in a web browser. The game’s code is written in JavaScript, which is a programming language that can be run directly in a web browser. The game’s graphics are rendered using HTML5, which is a markup language that allows for the creation of interactive web content. Together, these technologies allow for a fully playable version of DOOM to be run in a web browser.

    Can I modify JavaScript DOOM?

    Yes, you can modify JavaScript DOOM. The source code for the game is freely available on GitHub, allowing anyone with knowledge of JavaScript and HTML5 to make their own modifications to the game. This could include changing the game’s graphics, sound effects, or gameplay mechanics, or even adding new features or levels to the game.

    Is JavaScript DOOM legal?

    Yes, JavaScript DOOM is legal. The original DOOM game was released as open-source software by its creators, id Software, in 1997. This means that anyone is free to use, modify, and distribute the game’s code, as long as they comply with the terms of the original license. JavaScript DOOM is a derivative work of the original DOOM game, and as such, it is also covered by this license.

    How can I play JavaScript DOOM?

    To play JavaScript DOOM, all you need is a web browser that supports HTML5 and JavaScript. This includes most modern web browsers, such as Google Chrome, Mozilla Firefox, and Microsoft Edge. Simply navigate to the JavaScript DOOM website, and the game will load directly in your browser. No additional software or plugins are required.

    Can I play JavaScript DOOM on my mobile device?

    Yes, you can play JavaScript DOOM on your mobile device. The game is designed to run in any web browser that supports HTML5 and JavaScript, which includes the browsers on most modern smartphones and tablets. However, the game’s controls may not be optimized for touch input, so your experience may vary depending on your device.

    Does JavaScript DOOM have multiplayer?

    No, JavaScript DOOM does not currently support multiplayer. The game is a single-player experience, allowing you to play through the original DOOM campaign on your own. However, because the game’s source code is available on GitHub, it is possible that multiplayer functionality could be added in the future by a third-party developer.

    Can I save my progress in JavaScript DOOM?

    Yes, you can save your progress in JavaScript DOOM. The game uses the web browser’s local storage feature to save your progress, allowing you to pick up where you left off even if you close your browser or turn off your computer. However, please note that your save data will be lost if you clear your browser’s local storage.

    Is JavaScript DOOM free?

    Yes, JavaScript DOOM is free to play. The game is a non-commercial project, created by fans of the original DOOM game for the enjoyment of others. The game’s source code is also freely available on GitHub, allowing anyone to download, modify, and distribute the game at no cost.

    Can I contribute to the development of JavaScript DOOM?

    Yes, you can contribute to the development of JavaScript DOOM. The game’s source code is hosted on GitHub, a platform that allows for collaborative software development. If you have knowledge of JavaScript and HTML5, you can contribute to the game’s development by fixing bugs, adding new features, or improving the game’s performance.