Last week I talked the talk about “going cross-platform”. This week I started walking the walk. As expected, it’s been mostly up-hill so far. There is a reason the vast majority of games aren’t available on multiple platforms, and that is because it is less than easy to do. In this entry I would like to describe a few of the nitty-gritty details I’m dealing with to get this cross-platform idea off the ground.
I think one of the major misconceptions that non-programmers have about game development in general is that all this stuff is pretty standard right? Should be easy to do right? I mean, games are everywhere! Heck, you already have Ace1 running on iOS, so can’t you just “port” it? Unfortunately, that’s easier said than done, which is why a lot of developers go with a third-party “game engine” like Unity3D. We very seriously considered going that route ourselves, but for several reasons, which I may get into in another entry, we decided against it. So I’m on my own trying to figure this one out, and it has been quite the challenge!
First, let’s talk about the basic tool needed to construct a game (or any app for that matter). On the Mac (and for iOS), the main tool everyone uses is called Xcode. It is what we call an IDE (Integrated Development Environment). There are other IDEs which you will find on other platforms, for instance, Visual Studio on Windows. The main point to realize is that they’re all different, just like word processors are different, even though they do the same thing. To make Ace2 work on Windows and Linux I would have to know how to use three different IDEs and set up the project on each one, which is a lot of work. Fortunately, there is an alternative, called “GNU make”, which I will refer to as make for short. make is available on many platforms, including Mac/Win/Linux, and can be used for iOS and even Android too, which is exactly what we need. Unfortunately, learning how to use make isn’t something I’ve been able to pick up very easily. make is completely text-based, and is a command-line utility. If that sounds user-unfriendly to you, then you understand the situation perfectly.
If I were to describe make in one word, that word would be: esoteric
intended for or likely to be understood by only a small number of people with a specialized knowledge or interest
In my years of experience I have observed that the majority of programmers tend to avoid using make. Most prefer to manage projects in a more graphically visual way, using an IDE. There are good reasons for that, and I would suggest that I think the main reason is because it seems a lot more difficult to read through the bewildering amount of gobbledygook that command-line tools, such as make and gcc, tend to take in and spit out, much less just trying to learn to use them in the first place. That said, most of the good software you’ll find out there is managed with make. If you’ve ever downloaded an open source Unix program, you’ve probably seen all the funky files, one of which was probably titled “Makefile”. If you drag that Makefile onto Text Edit you can see what’s inside it, and chances are, if you’re like me, you probably had no clue what all that garbage meant and promptly closed the window. Well this week I spent some more time studying up on what that junk means.
make looks for a file called Makefile or makefile or GNUmakefile when you type “make” in Terminal in that directory. It opens that file and reads the junk written in there to figure out how you want it to build your project. Basically a Makefile is just a fancy script, containing recipes for how you want each part of your program made. When writing a Makefile, you’re basically programming the computer to make your program. The language used in a Makefile doesn’t have a proper name that I know of. It’s a combination of keywords and syntax, mixed with shell commands.
Simple Makefiles are not a big deal to learn how to do. Unfortunately, what we’re going to be doing with Ace2, including it being cross-platform compatible, means we’re going to be needing some non-trivial things done with the build system, and that is taking me some time to sort out by learning the voodoo Makefile incantations needed to automate the build process for that. Mostly this week I’ve spent lots of time reading and studying about make, gcc (the compiler), and SDL. It’s been one of those back-to-school weeks for me.
In closing, I’ve started to become fond of how make works. I think I like it!