Game Programming for Beginners

iDevGames Jan 10, 2013

Game Engines / Frameworks / Creators

For the latest information on game engines, frameworks, and game creator tools for Mac and iOS games, see the iDevGames Big List of Mac and iOS Game Engines.

The Tools

To build and test your game, you’ll need some sort of tools. If you’re using a compiled language such as C, C++, C#, Java, etc, you’ll need a compiler to compile your code and produce the built binary application. You’ll also want a nice “programmer’s” text editor with syntax coloring and other features to write your code in. There are dozens of compilers and text editors out in the wild, but generally only two which get used for development on Apple platforms.


Created by Apple, Xcode is the IDE (Integrated Development Environment) for developing applications for Mac OS X and iOS. Xcode compiles numerous languages, including the big hitters like C, C++, Objective-C, and Objective-C++, and even has capabilities for other languages like AppleScript and Ruby. It’s a fully graphical development environment with checkboxes and buttons galore for handling all of the configuration and build processes involved.

Xcode also has integration with source control management (SCM) systems, like Subversion and git, a full featured debugger, and integration with other Apple tools like Instruments for doing performance analysis of your code. If you’re going to be writing games on a Mac, you should become very familiar with Xcode.


Make is a UNIX command that’s used to compile applications on the command line. At it’s core, Xcode is basically just a graphical version of what Make and a plain text editor can accomplish. Some developers prefer the IDE approach in Xcode, while others swear by a classical model using Make. If you’re entirely new to programming, Make has a higher learning curve than Xcode, so to get settled in and building will take longer than simply firing up Xcode and clicking a “Build” button.

The Libraries

With the idea, language, and tools chosen, the last step is to pick and choose some appropriate libraries to help you with your game. A library is just a reusable collection of code. Some of the areas where libraries come in handy are sound, graphics file handling, and physics. The need to add these elements to games is so universal that there’s no point in trying to reinvent the wheel yourself, you should really just leverage the work of others.


a) SDL

SDL is a large cross-platform framework which helps with several elements in your games. SDL can help you receive input events from the mouse, keyboard, and controllers, setup your game’s window, deal with OpenGL a little bit for you, and more. SDL is used in many many cross platform games, even ones like Unreal Tournament 2004. Typically, developers who want to create cross platform games will use SDL to handle pieces which would normally require writing platform-specific code (like event and window handling), and then use other libraries such as OpenGL for graphics, and OpenAL for sound.

b) OpenGL

For high performance 2D or 3D graphics, look no further than OpenGL. OpenGL is a cross-platform and hardware-accelerated graphics library at the core of many games. Whereas Direct3D only works on Windows and Xbox, OpenGL is supported on Windows, Linux, Mac OS X, iOS, and even the Nintendo Wii. Although OpenGL is a 3d graphics library, it’s also very well suited and widely used for 2d games. Learning OpenGL is actually easier than you might think. To begin, many developers recommend reading the famous NeHe tutorials.

c) libpng, libjpg , …

There are a bunch of other graphics libraries. These are usually used to load an image from your hard disk and convert it to a texture so you can use it in OpenGL. Do a Google search and you’ll find some interesting links about them. There are Apple-specific APIs in Cocoa and CoreGraphics which can load images as well, but they are inherently not cross platform.


a) QuickTime / Cocoa / Core Audio

Using the Cocoa class NSSound is by far the easiest way to get sound into your game, but it is also pretty limited in capability, so it’s only appropriate for 2d sounds as in board games. QuickTime offers much more capability for media, but is not really appropriate for sound in games either. QuickTime can, however, be useful for reading audio files and getting at the raw data to pass off to other libraries such as OpenAL, but even for that it’s not as common as it once was. Core Audio is a very low level audio API for Mac OS X and iOS which provides complete control over audio, but it’s also very difficult to work with, requiring quite a lot of setup and understanding. None of these APIs is a great solution for most games.

b) OpenAL

OpenAL is designed very much like OpenGL but for audio. This framework allows you to position and mix sound in a virtual 3D environment, making it perfect for 3D games. As long as you can read the file format, OpenAL will work with any kind of audio file, such as WAVs, and OGG/Vorbis so is a great choice. OpenAL is freely available and is what many indie games use.


FMOD is a commercial audio library this is quite popular in commercial game development. While many developers use OpenAL because it is free and familiar to OpenGL, FMOD supports a large number of file formats and platforms out of the box, and has numerous advanced capabilities such as geometry-aware audio rendering. If you’re planning on making free games, FMOD does have non-commercial license allowing it to be used for free in non-commercial games.

uDevGames 2011

Convergence — Best Gameplay
Kung Fu Killforce — Best Overall Game, Best Audio, Best Presentation
Flying Sweeden — Best Graphics, Most Original
Time Goat — Best Story