One-week-game: getting ready

Ok, so if you want to benefit the most from the one-week game I’m going to “live develop”, the best thing you can do is to follow and develop along. You can just read the source code and other materials I post, but nothing beats doing it with your own hands too, and seeing the thing grow from nothing into a cool little game.

Let me review the two most important things now: the previous knowledge you should have, and how to set up your development environment.

Required knowledge

First thing, you need to know some programming. It’s impossible to get up to speed from zero into game development in one week.

But if you have some experience programming in nearly any common language (java, javascript, python, php…), then it should be really easy for you to get up to speed.

We are going to use the C language, in its most basic form, without using pointers. Here is the list of C features we are going to use:

  • global and local variables: char, int, float, bool
  • enums
  • functions and function declarations
  • expressions, operators, assignments, statements
  • control-flow: if-else, while, for, break, continue, return
  • comments
  • arrays
  • structs
  • typedef
  • preprocessor: #define, #include, #ifdef/#endif
  • file access (functions open(), read(), write(), close())

Hopefully this should be pretty easy to grasp in a few hours. Here are some link to the online C tutorials that look best after having a quick look at the top Google results:

Now, you should have a bit of basic math knowledge, basically some geometry and algebra. Here is what we are going to use:

  • 2D coordinates and coordinate systems
  • Vectors, vector addition and subtraction, scaling, distance measures
  • I will try to completely avoid calculus and trigonometry, but I’m not 100% sure I’ll be able to. If you need it, just understanding sine and cosine should be sufficient.

Although we are going to use it, you don’t need need any previous OpenGL knowledge. We will explain it as it is used.

Development environment: OS X

You can follow along easily on OS X. You need a Mac with a reasonably recent version of OS X. I’ve tested things on 10.7 (Lion) and 10.8 (Mountain Lion), but you should be able to use anything from 10.5 and up.

You need to install the following:

  • Xcode. It’s free to install from the Mac app store, so you can probably install the latest one (I don’t recommend the Xcode 5 developer preview). I’ve tested versions from 4.3 and up, although it’s likely old versions will also work, since we’re not using anything cutting edge here.
  • Xcode command-line tools: once Xcode is installed, go to its preferences dialog, select the “Downloads” tab, and install the command line tools.
  • GLFW library: you need to install the GLFW library, which is one of the best ways to do OpenGL apps on OS X nowadays without using Objective C. It has to be installed from source. We are going to use version 2.7.9, to totally avoid pointers (not doable with GLFW 3.0). Download from Uncompress it in some temporary place, go there with the shell, and type “make cocoa”, then “sudo make cocoa-install”. [NOTE: A reader over at Reddit suggests that if you’re using Hombrew, typing “brew install glfw” will do the whole thing. Haven’t tried, but it looks like it should work, and it’s GLFW 2.7.7, which is fine. Good luck!].
  • Graphics tool: to generate the type of graphics we will be using (32-bit BMP files with alpha), you need to install the free Paintbrush tool from here: , which is able to generate the format we want. Other tools probably can generate it too.

The audio API we’re using, is directly supported by OS X, so that’s all.

Now let’s test it. Open Xcode, select “New project”, choose “OS X, Application, Command Line Tool”, choose whatever name (I chose “SCTest1”), type C++ (I’ll explain why later), and do not check “Use Automatic Reference Counting”). Once created, inside the main.cpp file that Xcode created, put in the following content (don’t worry about understanding it yet, we’re just testing that your system is properly set up):

To get it to build, you also need to do the following steps:

  • In Build Settings, and enter “/usr/local/include” for Header Search Paths and “/usr/local/lib” for Library Search Paths (for Xcode to find the GLFW library)
  • Also add the options “-lglfw” to the “Other Linker Flags” setting
  • Select the “Build Phases” tab, open “Link Binary With Libraries”, and add the following frameworks: OpenGL, OpenAL, IOKit and Cocoa
  • Mute your speakers! The sample makes some ugly noise.

Now it’s ready, build with Cmd+B and run with Cmd-R. Be careful as it will make an ugly noise! You should see a rotating square on the screen and hear some noise. If so, you’re ready. If not, check all steps, and if you can’t fix it, post in the comments below.

Development environment: Windows

Windows XP or later will do, on basically any less than 8 years old. You will need the following:

That’s all. Let’s test it:

Open Visual Studio, select “File, New Project”, “Visual C++”, “Win32 Project”, choose whatever name (I went “SCTest2”), including “Create New Solution”, then “Windows Application” in the settings. Once created, substitute the contents of the main file (SCTest2.cpp in my case) with the following:

No need to understand it now, we’re just testing your set-up.

Now you need to fix the following settings:

  • Right-click on the “SCTest2” node on the solution explorer, properties, “VC++ Directories”. Click “Include Directories” to edit it, and Add “C:\Program Files\OpenAL 1.1 SDK\include”. Also add “C:\Program Files\OpenAL 1.1 SDK\libs\Win32” to “Library Directories”. (Please check your system: depending on where OpenAL was installed, you may need to use “C:\Program Files (x86)” instead!)
  • In “Configuration Properties”, “General”, setting “Character Set”, set it to “Use Multi-Byte Character Set”.
  • In “Linker”, “Input”, “Additional Dependencies”, add “opengl32.lib;openal32.lib;” to the front.
  • Mute your speakers! The sample makes some ugly noise.

We should be done now. Check building it with “Build”, “Build Solution”, and then check running it with “Debug”, “Start Debugging”. You should see a Window with a rotating pattern, and noise coming out from your speakers. If so, congrats! You’re ready.

Development environment: Linux

I haven’t had the time to check this, but it should be simple if you install GLFW (I think with the same instructions as for OS X above), and OpenGL & OpenAL (use your package manager to search, “apt-cache search openal” or “yum search openal” should help, and there is some help on StackOverflow too).

A note on C and C++

C++ is basically an extension of C, adding object-orientation and other advanced features. Anything you code in C can be compiled as C++. I am not going to use any feature of C++, I am going to compile all our code as C++ just to make use of two minor things from C++:

  • Easy use of inline functions
  • Use of struct/enum types without typedefs or prepending ‘struct’ or ‘enum’ to all declarations

So, technically, we are already using C++ (although barely so). If you follow down the road we’re setting up, you will be moving to using more and more C++ in the future, so it’s not a bad thing. But you better know the details in case someone asks!


If you have any question, or any issue getting this to work, just post a comment below and I’ll try to help. Good luck!

And if you want to be notified when new articles to help you become a games developer are ready, just fill in the form below:

Subscribe to Gamecrash mailing list:

* indicates required