JSQuake2 – A JavaScript port of Quake 2

Through the years ID software has released the source-code of various games they produced. One of these games was the world famous Quake 2 game, which was the origin of many games developed afterwards. Games directly or indirectly based of the Quake 2 game engine include Half Life, Daikatana, Kingpin, SiN, Soldier of Fortune and many, many others.

In an attempt to learn a bit about game engines and game building I decided to try and port the Quake 2 game to JavaScript straight from it’s original ANSI C source. Over a couple of months a lot has been implemented and technically a lot of behind the scenes things are working and verified to be correct. The original plan was to implement the software rendering engine Quake 2 was using, which unfortunately came to a halt, due to the performance of the HTML5 Canvas 2d-context performance as well as the payload that software rendering gives to the JavaScript engine.

Although quite a bit of the Quake 2 source has been ported it’s far from completed. I’m currently at a point where I’m in doubt if I should continue porting the code the way I’m doing now, or that I should start to do some refactoring first to make certain elements of the current implementation faster and less likely to break. For now this project is therefore on hold until I have decided what to do with it.

What got ported:

  • Client-Server communication model
  • .PAK file loading and processing
  • Resource loading and handling
  • Demo playback (including all client-server communication)
  • Map and model loading (and processing)
  • Game console (rendering)
  • Game HUD (rendering)

Still to do:

  • Actual game-play
  • World rendering

At this time I will now release any of the source-code yet as I want to do some cleanup of the code first. If I decide to continue on the project I will later release the source-code so you can play with it yourself and use if for building your own game around the Quake 2 engine, or just use it as a reference to learn how to build a full game engine in JavaScript.

Here is a screenshot of the current state of the project. I’m currently in a refactoring phase, so a lot that is actually implemented already, doesn’t actually work at the time of this screenshot.