Going multi-platform, part 1 : The setup

As mentioned in my agenda for 2013 (and in several older posts), I’ve been wanting to release “Phase 2” of Projekt W on more platforms than just windows. Especially in the developer community linux has a big fan base, and the bigger the audience for the game, the better.

So shortly after the last post I updated my lazarus installation to the latest one (along with a current FPC compiler) and started to make the code compile with it. I already hinted at the fact that this required changing thousands of lines of code to make the game compileable with free pascal (which is the first step to getting it onto multiple platforms, Delphi isn’t a choice for that). And that’s exactly what I did. So for the complete last week (and weekend) I’ve put all my spare time in getting the code ready for lazarus, and considering that I’m coding 8h a day for living it was a bit tiresome, but I’m the kind of guy that likes to get things done once started.

The biggest part was to replace the all of Delphi’s xml functionality cause it’s based on windows xml libraries¬† and it also has a different syntax than the xml implementation of free pascal. But since I want my code to compile with Delphi and FPC (I’d like to keep all options open, e.g. Embarcadero’s announced mobile studio with android support) I opted for NativeXML instead, an open source library that’s self-contained, works with Delphi and FPC and works on different operating sytems. And it’s a lot faster than the implementation of Delphi, so the next release of the game should load a bit faster. Other than that there wasn’t much to do. Some IFDEFs here and there for slight syntax differences between FPC and Delphi (e.g. in the generics implementation) and different units to be included.

And so I was finally able to compile the game with free pascal and with a few small fixes it’s now completely playable and performance is on par with the Delphi version . There are still some visual glitches and some of the text labels aren’t filled with language specific texts, but that’s nothing that can’t be fixed within a day or two.

After I got it to compile and run with free pascal under windows the first big step towards multi-platform support was completed. And just before writing this post I’ve set up a linux and got lazarus to work there. I must admit though that it was a real pain compared to getting Lazarus set up for windows. The user interface of Ubuntu 12 is just horrible (I’m actually shocked at it’s bad usability) and getting Lazarus to work there had me install a total of 10 packages, and none of the required vesions could be installed by the package manager. So compared to the 3~4 minutes you need under windows, it took me almost an hour to get it up and running. But the virtual machine is saved, so no need to do this again.

So now everything is set up to start porting the game to Linux (with other platforms to follow), so hopefully I’ll be able to release a current snapshot of the game for two platforms, with more platforms (Mac OSX will be next) following sometime in the future.