Two years ago, I released Exp3D on Google Play, a fast-paced space shooter I had been working on during my free time.
To celebrate this anniversary, the entire code of Exp3D has now been made freely available on GitHub. Not that I am especially proud of the code – there are hacks I didn’t have time to clean-up, some parts of the code now look dirty to me and I would rewrite them totally differently – but I received some requests for open-sourcing the game in the past and I figured it might be interesting for people who want to play with the code.
The game runs on top of a minimalistic multiplatform framework I wrote from scratch.
The source is entirely in Java, there is no “native” code included.
The main loop doesn’t perform any dynamic allocation to maintain a constant 60FPS with 0 GC pauses, this was achieved by relying heavily on object pooling.
95% of the code (25k lines) is written on top of this framework and thus is shared between the different platforms.
The rendering engine can run on either a fixed-pipeline (OpenGL ES 1.1) or a programmable-pipeline (OpenGL ES 2.0, WebGL).
If you want to know more details about the architecture of Exp3D you can read a post about it on the Breaking Byte blog.
And I am pleased that after 2 years, the WebGL demo finally runs butter smooth on Firefox and Chrome. The code was never especially heavy, but I used to notice a few frames dropped here and there, which is not happening anymore.