The classic game Doom has been ported to the browser through JavaScript, fully demonstrating the capabilities of this most commonly used programming language in the world.
Main gains:
Please forgive the obvious click induction in the title. JavaScript is good. The most commonly used programming language in the world has a bright future – especially after id Software’s Doom is ported to the browser to run! If you are excited, stop reading and click on the link: developer.mozilla.org/demos/detail/doom-on-the-web/ (Note: This link may be invalid at the moment, please refer to the video on YouTube.) The game is available in Mozilla's Demo Studio; the resource shows HTML5, CSS3, and JavaScript technologies in Firefox and other browsers.
If you've never heard of Doom, it's a first-person shooter for PC released in 1993. While it is not the first first-person shooter – id Software’s Thor Hammer 3D is the originator – Doom has revolutionized the genre. Its groundbreaking 3D graphics, multiplayer games and bloody chainsaw violence scenes have become the inspiration for many of today’s big games.
By modern standards, Doom has already seemed a bit outdated. It has outdated block VGA graphics, 2D maps (the walkways cannot overlap each other) and limited control (no jumping or aiming vertically). But the gameplay is still amazing, Doom has been ported to various consoles and handheld devices. Now, it has been ported to JavaScript and can run in the browser without plugins.
Unfortunately, the JavaScript version of Doom runs very slowly in Chrome and cannot run in IE. Some versions of Safari are reportedly available to run, but this is not the case in my version 5.0.5. However, it works well on Firefox 4 and Opera; mid-range PCs should be able to hit 20-30 frames per second—perhaps better than the old 486 I used when I played Doom in 1993! Although there are some graphics failures, it is still playable.
Amazingly, the game compiles C code into JavaScript using Emscripten and Clang, and then optimizes it using Google's Closure Compiler. Video output is rendered on standard HTML5 canvas elements. The sound is processed using Mozilla's non-standard Audio Data API, but it works poorly and you may not want to use it! If you are interested, you can download the source code, although JavaScript has been compressed and difficult to read.
If you think this is impressive…
Fabrice Bellard has developed a JavaScript version of x86 PC emulator. Just for fun. It works in all the latest browsers, so it installed the 2.6.20 Linux kernel and released a browser-based emulator. Yes, it runs Linux in a web page. The demo version is limited to terminal output rendered in HTML tables, but it is of great significance. My only concern is that someone will add X11, install the browser and recursively crash the web! Have you seen other excellent cutting-edge JavaScript examples?
(The following is the FAQ part, the content is basically the same as the original text, but the expression and order are adjusted, and some duplicate information is simplified.)
Frequently Asked Questions about Doom in JavaScript (FAQ)
What is the JavaScript version of Doom? JavaScript version of Doom is a version of the classic video game Doom, which has been rewritten in JavaScript and can be run in a web browser. This allows the game to run on any device with a web browser, without any additional software or plug-ins. The game retains all the original features, including graphics, sound effects, and game mechanics, providing a nostalgic gaming experience for fans of the original Doom.
How does the JavaScript version of Doom work? JavaScript version of Doom recreates the original Doom game in a web browser by combining HTML5 and JavaScript. Game code is written in JavaScript, a programming language that can run directly in a web browser. The graphics of the game are rendered in HTML5, a markup language that allows the creation of interactive web content. Together, these technologies enable a fully playable version of Doom running in a web browser.
Can I modify the JavaScript version of Doom? Yes, you can modify the JavaScript version of Doom. The game's source code is available for free on GitHub, allowing anyone who knows about JavaScript and HTML5 to modify it. This may include changing the game graphics, sound effects, or game mechanics, or even adding new features or levels to the game.
Is the JavaScript version of Doom legal? Yes, the JavaScript version of Doom is legal. The original Doom game was released as open source in 1997 by its creator id Software. 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 version of Doom is a spin-off of the original Doom game and is therefore protected by this license.
How to play "Doom" in JavaScript? To play Doom in JavaScript, you only need 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 plug-ins are required.
Can I play Doom in JavaScript on my mobile device? Yes, you can play Doom in JavaScript on your mobile device. The game is designed to run in any web browser that supports HTML5 and JavaScript, including browsers on most modern smartphones and tablets. However, the game's controls may not be optimized for touch input, so your experience may vary from device to device.
Is there a multiplayer mode for the JavaScript version of Doom? None at the moment. The game is a single player experience that allows you to play the original Doom campaign alone. However, since the game's source code is available on GitHub, third-party developers may add multiplayer features in the future.
Can I save the progress of the game for Doom in JavaScript? Yes. The game uses the web browser's local storage feature to save your progress, allowing you to continue the game from where you last interrupted even if you close the browser or shut down your computer. However, be aware that if you clear your browser's local storage, your saved data will be lost.
Is "Doom" free in JavaScript? Yes, Doom is a free game in JavaScript. The game is a non-commercial project created by fans of the original Doom game for entertainment. The source code of the game is also available for free on GitHub, allowing anyone to download, modify and distribute the game for free.
Can I contribute to the development of Doom in JavaScript? Yes. The game's source code is hosted on GitHub, a platform that allows for collaborative software development. If you know JavaScript and HTML5, you can contribute to game development by fixing bugs, adding new features, or improving game performance.
The above is the detailed content of JavaScript Doom. For more information, please follow other related articles on the PHP Chinese website!