Snaeks: A Golang Game Experiment

Jun 06, 2017

Curious about the state of OpenGL development in Golang, I decided to experiment by cloning a somewhat simple game. My inspiration is the game splix.io, which itself is based on the classic arcade game Qix.

Here's a video of the gameplay:

I planned to eventually turn this into an online multiplayer game, but I never got that far. I also haven't managed to run this on anything but macOS, but it should technically be possible to cross compile to iOS and Android using gomobile. Unfortunately, the tools don't seem to be there yet. I also experimented with running it in the browser using gopherjs, which worked, but was far too slow. In that case, the problem is likely to do with the fact that I made heavy use of goroutines to avoid blocking the render loop, but the single threaded nature of javascript essentially eliminates the value of doing so. I suspect that the best way to move forward with running this in the browser would be to move most of the heavy game logic to a server, i.e., the AI and the floodfilling.

Build target limitations aside, I found that working with raw OpenGL in Go to be possible, at least. Increasing the graphical complexity might get out of hand quickly without some kind of framework or engine. I can see a need for something like a Go equivalent of THREE.js, if only for the scene graph and material/geometry/mesh abstractions. Maybe I'll find a rainy day to make a start in that direction.