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

46 thoughts on “One-week-game: getting ready

  1. There’s a little bug in the code for MacOS X on line 83 (just remove the last &&). After correction everything works.
    P.S. Next time tell us to mute speakers before running the code 😉

  2. Thanks Ilanders, you actually caught me with an intermediate version of the code, while I was doing tests & last minute changes… bad of me to publish and then review! I will add a more prominent mention about speakers :)

  3. In Xcode, to learn how to access “build settings” you can use the following link :

    This took me all of 5 minutes to get the project set up and build/run the test on Mac OS X Lion. As llanders noted there is the invalid syntax error. The only other minor issue I ran into was that I didn’t know where to find “Build settings” since I am not typically a Xcode user.

    Thanks for doing this tutorial!

  4. Ilanders, antisyzygy, thanks, you were both right, I had fixed the issue in my copy of the source code but not in the one embedded in the article… fixed now.

    Indeed follow antisyzygy’s link above to access “Build settings” in Xcode. Hopefully the explanations above are enough without screenshots for every minor step. If there is any other issue, just post a comment and I’ll try to clarify, or edit the article.

    • I wasn’t trying to nit pick! Just trying to save people a little time who might be in my situation. I’ve never used Xcode before.

      Everything was pretty straight forward. I really appreciate you doing this series. Like many I’ve attempted projects here or there but never finished anything.

      • No prob, I’m grateful, any extra help you can provide to others is more than welcome! And I really hope that you and others can get from this series the experience to actually get your projects through the finish line afterwards.

  5. I am a bit confused about changing the settings, (right after replacing the default code with your own). I am using Visual Studio 2012.

    You say, “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’.”

    When I click on “Include Directories”, it doesn’t edit the box, it highlights the entire thing. So do I replace the string that is in there, or do I just want to place your property at the end of the field?

    I tried simply replacing everything and completed the rest of the directions and had tons of errors when I compiled.

    Any help would be appreciated!

    • Jeremy, no prob. You have to add those directories to the front of whatever is configured. It probably has several entries separated by colons, add the new one also separate by a colon.

      BTW, depending on your version of Windows, you may need to use “Program Files (x86)” instead.

      Hope that helps!

      • That was it! I am running this on Windows 7 64-bit, so I just needed the “Program Files (x86)”. All compiled and ready to go.


  6. Excellent intro post.

    I’m reading in the pub right now so I can’t set up and follow along, but well written, clear and concise. I’m definitely looking forward to the rest of your articles in the coming week.

  7. Hey Jon,
    I’m all set up to start :-)
    I don’t know how difficult the graphics are going to be, but I suggest that everyone uses pinta ( ). It’s inspired by, but it’s available on Windows, Linux and OSX, so you don’t have to do extra work to show how to do something on each platform. Unless, of course, there’s something about pinta that doesn’t go well with your workflow.
    Whatever the case may be, I’ll be following you throughout this project, hoping that I’ll finally get to the stage that I can create my own games.

  8. Hey, Jon.

    First of all, thanks for this course. I’m a programmer and I’ve always been interested in game programming but I never had the time to learn it properly, so I’m looking forward to learn as much as I can.

    Just a little question: could it be possible to use Dev C++ in Windows instead of Visual Studio? It’s not a problem for me to use VS, I was just wondering if I could use Dev C++.


    • We are not doing anything weird, so I guess it’s usable. I seem to remember someone was trying to and possibly managing to. Unfortunately I’m not familiar with Dev C++ myself so I can’t really help much.

  9. Francis, will check out Pinta when I have some time, the key is whether it is able to write uncompressed 32-bpp BMP files with alpha.

    Al, if DevC++ can call OpenGL and link with the OpenAL SDK, there should be no problem. Just check if you can build the above sample program, if you can, then you can use it for the whole thing.

    • I’ve managed to call OpenGL with the instructions I found on this website: I paste the url here in case someone else wants to work with Dev C++, after following these instructions I executed the above sample program and it ran smoothly, with no warnings or errors, and displays the animation correctly,

      As for OpenAL SDK I can’t get it to work. I installed the SDK and added the libraries to the project but no sound is played when I run the sample program.

      • If it’s compiling & running, then OpenAL SDK installed fine. If there’s no sound, I’d run the OpenAL runtime installer, possibly that’s the issue.

  10. This looks like a fun project to jump on so thanks for doing this. I’m headed back to school in a week, and this is a very engaging way to review material I might not touch otherwise, but I might try to pull in other topics fromC++ in addition to what you are doing.

    hope to have a good time!


  11. Hello, I’m getting this error when I try to build:
    1>LINK : fatal error LNK1104: cannot open file ‘openal32.lib’

    I’m on Windows 7 64-bit using MS Visual C++ 2010 Express.

    I installed the required audio SDK. I checked and verified that openal32.lib is within /libs/Win32 and that the dependency paths are set. Thanks for your time.

    • Jiffygast, that error means VS is not able to find the OpenAL library file.

      First thing, locate where the SDK was installed – by default, it’s in a subdirectory under “Program Files”, but it could be “Program Files (x86)” on your system, or something different. Just search for openal32.lib in your hard drive.

      Second, we gotta tell VS where to find it. That’s what the modified “Library Directories” entry is in the VC++ Directories area. Make sure the first entry before the first colon is exactly the path where the openal32.lib file is. Copy it with Ctrl-C and paste it in the address bar of an explorer window if necessary, to make sure it’s fine.

      Things should work after that.

      • Eh, hate to be a bore, but it’s still not working for me :(
        I’ve got the directory paths in there right, I’m quite sure, and it has no problem finding the include files. I can see the openal32.lib sitting in the libs\Win32 folder in my explorer, but VS isn’t for some reason, it seems.

        • 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”.

          Confused me at first too. You need to add a line to both “include directories”
          and also, on a different line “library directories”

          (I initially added them both to “include directories”)

        • I’m having the same exact issue. The .lib file is in the right place. The ‘include directories’ and ‘library directories’ both include the correct paths, but I still get the ‘OpenAL32.dll was not found’ error. Any solution to this yet? I’m sure I’ve followed the exact directions specified this far.

          Running win32

          • Edit:
            I uninstalled and reinstalled OpenAL, making sure not to include the helper thing and I also took the spaces out of the “OpenAl 1.1 SDK” part, so that it now looks like “OpenAl1.1SDK”. I rebuilt it and ran the debugger and it worked… Which was weird because I had just uninstalled it and reinstalled it under a new directory and the old solution still had the same properties from my first attempt… (IE the path with the spaces in it) What’s with that? How could that possibly work?

            I remade the test project and ran it again and everything worked this time… So unless I’m overlooking something, the problem was with one of the following things:

            1. The first time I installed OpenAl I might have included the help files. The second time I did not. (What are these anyway?)
            2. I changed the installation directory name to leave out spaces. I then changed the properties accordingly.
            3. I might have made a typo or some other error the first time I was changing the properties.

            Let me know if this helps else with the problem

      • Not working for me still :/ i found the file in the explorer window, and copypasted the path into the VC++ Directories area, and made sure to add the $ at the front and the ; at the end. Im not really sure what else i can do here. any suggestions?

    • I had the same problem and I think it stemmed from being installed on a different drive. I moved the .dll file to the source location and used that and it worked fine.

  12. Platform: Win 8, VS Express 2012

    When I attempt compile and run the test program I get an “error C1083: Cannoto open include file ‘al.h’: No such file or directory,” and subsequent errors relating to the missing AL library.

    When I installed the OpenAL SDK I made sure to install the redistributable, but a separate installer didn’t pop up after I pressed “next”, so I’m not really sure if that worked. Do I need to manually put the OpenAL header files on a special VS path or something to get it to work? I was under the impression the SDK installer would put them in the right place out of the box.

    • Similar to the issue Jiffygast has above, this means VS is not able to find the files. On Windows, SDK files are typically installed in their own path (OpenAL defaults to a directory under Program Files), and then you have to configure your compiler to make sure it finds them. This configuration is as simple as a list of directories where the compiler should look for header files and library files. That’s what I am modifying in the “VC++ Directories” above.

      So the way to fix it should be simple: find where in your disk drive OpenAL was installed (in the worst case you can resort to searching for al.h in your hard drive), and then making sure that directory is configured in the list “Include Directories”. Hope that helps!

  13. Note about Linux: user Indubitableness over at the gamedev subreddit got it to compile with Linux and posted the following:

    Update: Using the test code written for OSX, I compiled and ran the test program on Linux. In the code I had to make one change in two places.

    The preceeding lines needed to be changed to:

    Despite the example compiling the code as CPP I used the gcc compiler. I needed to run the following command:

    Actually I just let it use the default output file of a.out but the preceeding line of code will produce an executable file named test.exe. Don’t have your speakers too loud when you run it.

    Thanks so much!

  14. Hey, cant wait for you to start!
    Im on V7 with VS Express 2012
    When ever I build solution it gives me an error saying that openal32.lib; could not be opened! But everything else works!

    • You will get actual errors instead of warnings once we add sound support. The issue is most likely in the “Library Directories” setting, make sure it’s pointing to the directory where OpenAL installed the .LIB files.

  15. Thanks for doing this. Code is up and running which for these kinds of things is further than I’ve gotten with others.

  16. Nice, got everything up and running. Now to figure out how to get my vim color scheme into XCode. 😀

    I highly recommend using Homebrew ( ) to install GLFW on a Mac, as it keeps everything nicely under /usr/local and will make cleanup/upgrading/managing library versions easier later.

  17. Jarin, thanks indeed for your suggestion. It seems “brew install glfw” will do the trick, I added a note above earlier today.

    And just a suggestion, if you are a vimmer using Xcode, you could definitely do worse than use my product ViEmu ( :)

    • If you’re talking about the Paint.NET plug-in: extract the two files, and copy them in the “FileTypes” directory inside Paint.NET’s installation directory (typically “C:\Program Files\Paint.NET”).

  18. Getting this error when I try to build. I’m on win7 using vc++ 2010

    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\windows.h(151): fatal error C1083: Cannot open include file: ‘excpt.h’: No such file or directory

  19. Pingback: Game developer with over 20 years of experience

  20. If anyone is having trouble with the build, look at the error message and check if it says anything about al. or alc.

    It took me a while to realize that for some reason typing in the directory for AL 1.1 wouldn’t suffice and I had to use the browse option to select the folder

Leave a Reply

Your email address will not be published. Required fields are marked *