I have figured out how to make browser builds of my games. It all started as a fun little toy project that I undertook to get back to business after the holidays, but I soon realized that it's not going to be a toy at all.
It feels a bit like I had just coded and slept on rotation for almost a week, and it's probably because I more or less had. But sometimes you just get excited about your pet project and forget everything else. Technical challenges like this always get me hyped for some reason.
Anyway, the browser port is actually just a Java project that has been compiled into JavaScript using dark magic tools from the web. The really nice thing about this is that I can now reuse the same game code on desktop, browser and Android. Essentially, if the game code doesn't do anything naughty, the browser port comes for free.
So, what is naughty anyway? Well, super common things like the Java file API. Yep, had to replace all that with interfaces that point to naughty things on desktop and not at all naughty things on the browser. Yep, nothing naughty about pretending that downloads and the local storage are a file system. But, well, that's how it is.
I most vividly remember the part about the porting process where my test application was running without errors but only showed a blank page and occasional flickering artifacts despite the rendering code being there. It turned out that I was writing data to the vertex buffer in big endian format on a little endian machine. No wonder the output was all over the place.
Once the basics were there, it was surprisingly easy. Almost scary even. Solstice Snow Globe itself just took like 2 days to get working.
