Gemstone Keeper – Quest to Linux Part 1 – Vigilante Framework

So with Gemstone Keeper on Steam for Windows only, I thought I’d try my hand at getting a game to build to Linux the proper way. This series of posts will hopefully document each part of porting Gemstone Keeper to run on Linux.

https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png

The last time I made a game with Linux support was Secret of Escape, which used the Node-webkit to run HTML5 games to desktop applications. Node-Webkit essentially was a separate, precompiled application that functioned like a limited web-browser using the Chromium engine, all Construct2 did was build a HTML5 game and structured it in a file structure that made the application run the game. This way, porting the game to Windows, Mac and Linux took very little effort. This essentially means that developing for Linux was a completely new thing for me before releasing Gemstone Keeper.

The first stage was porting the Vigilante Game Framework. This is the underlaying C++ framework that uses SFML to develop games with state management, collision, visual effects and audio effects among others. It was partially inspired by HaxeFlixel, although with some of my own approaches that rely on C++ and SFML, as well as my own features (such as circle collision, multipass post process effects and a custom text renderer). Getting this to work on Linux would help me with setting up SFML and having a good idea of how Linux development worked.

Surprisingly, getting the framework to build on Linux ended up being the easiest part, because someone else already did it! I posted the framework to GitHub, and passed around the GitHub page to Twitter and Reddit, and SirFrankalot on the /r/gamedev subreddit was able to fork it and get it to work in Linux, and provided both written notes and a pull request to carry his changes over! The details can be found here, but these are the main points I wanted to get across:

  • Using Correct Slashes: When using Windows Explorer and Visual Studio, folders or directories will usually be represented with a backwards slash (\). If you are only developing on Windows, this wouldn’t be a problem. However Linux and Mac both always use a forward slash (/), so for portability you should use that. Using forward slashes also has the advantage of not having to deal with escape sequences, since programming languages use a backwards slash (such as \n, \t and \\).
  • For-Loops: These kinds of loops are good for looping a specific number of times using a defined iterator. If that iterator is a list of object or variables, you use a foreach loop, assuming your programming language of choice has that. When using Visual Studio, I found there is a foreach loop in the form of for each (type x in y) where x is a reference to an object in the list, and y is a container like an array or vector. Turns out this way is purely a Visual Studio extension, and the portable foreach loop is for (type x : y).
  • XInput: Microsoft XInput is the API used for Xbox 360 and Xbox One controller, which means that it’s works for Windows only, at least that’s what you would assume. Linux has both libudev and linux/joystick.h, which allows some Linux OSes to access XInput functionality. This would mean a complete rewrite, so SirFrankalot simply made all XInputDevice functions return false. I later found someone wrote a Gamepad API was maintained long enough to allow Xinput Controllers to work on Windows and Linux using the same functions. I’ve since added this on as an optional feature that can be set using a preprocessor.

https://upload.wikimedia.org/wikipedia/commons/3/3f/Logo_Linux_Mint.png

Next was using an IDE, I decided to use Code::Blocks because I have used it before, although it’s still much of a change of Visual Studio. Not to mention I was using a virtual machine, a VirtualBox with Linux Mint 18.1, and for whatever reason my configuration causes it to crash with no warnings. I also had to set up a load of dependancies, although using the terminal to get them is much easier than browsing for libraries online.

 

In the end I managed to build the SFML tutorial code and a few moments later, VFrame could compile! Aside from some small issues with 3D graphics, it was running almost just like it did on Windows!

Next time, it’ll be my ramblings as I port over the library that makes Gemstone Keeper’s caverns large and random, the GenLevelTools!

3 thoughts on “Gemstone Keeper – Quest to Linux Part 1 – Vigilante Framework

  1. Pingback: Gemstone Keeper – Quest to Linux Part 2 – GenLevelTools | GAMEPOPPER

  2. Pingback: Gemstone Keeper – Quest to Linux Part 3 – Gemstone Keeper | GAMEPOPPER

  3. Pingback: New Years Resolutions | GAMEPOPPER

Leave a comment