Skip to content
 

Your First Automatic Program

If we’re going to write a video game, or a program of any sort, we’ll need to look into some of the tools of the trade. I’ve worked in several different environments, and you are going to end up doing the same (trust me), but for now I’m going to pick out two specifically that I’ve grown strikingly familiar with. If you install either of these two you’ll be able to follow along fairly easily with the tutorials I give, although I’ll be descriptive enough that with some finesse you can work in whichever you like. So, if you have your favorite programming environment set up, you can probably skip most of this post and come back toward the end.

Shawn Hargreaves is a bit of a personal hero to me, as far as game development, and he has a large hand in BOTH of the setups I’m going to introduce you to here. He started the Allegro C Game Programing Library, which is one of the setups I’ll work with, and is now a big player in Microsoft’s XNA development kit, which is the other. So without further ado…

Setting up Dev-C++ and Allegro:

1.) Download and install Dev-C++ from here, then run it.
2.) In the “Tools” menu, pick “Check for Updates and Packages”

Installing Allegro: Step 1

3.) At the top of the new window, pick devpaks.org Community Devpacks from the list of servers, and hit “Check for Updates” at the bottom.

Installing Allegro Step 2

4.) When the list has finished updating, scroll down until you see “Allegro 4.2.2″ in the list. Check it, and pick “Download Selected” at the bottom. When it’s done downloading, it’s safe to hit “Close” at the bottom right.
Installing Allegro Step 3
5.) When you do this, a new dialog will pop up to install the new plugin. Follow it’s “Next” button path until it’s finished.
Installing Allegro Step 46.) When all this is done, and you’re back at the main Dev-C++ window, pick “File – New Project”. In the tabs at the top, pick “MultiMedia”, below that pick “Allegro Application”, give it a clever name, and hit “OK”. It’ll ask for a location – Make yourself a folder you can find again easily (this is our starter game, so we’ll be coming back to it often).
Installing Allegro Step 57.) Now you have a screen full of odd-looking blue code. SAVE IT. I’m sure you know this by now, but it never hurts to SAVE IT. Let this be your mantra: Save Early, Save Often.
Installing Allegro Step 68.) Hit F9, or in the “Execute” menu, pick “Compile & Run”. So far all the program does is display a black window and wait for you to press Escape, but it’s more program than we had half an hour ago. We’re at a starting point!

Setting up C# Express and XNA Game Studio:

1.) XNA Game Studio requires either Visual Studio or Visual C# Express to operate. Get Visual C# Express at Microsoft’s Web Install Site, and install it per the instructions. Take the time to register it while you’re here, run it at least once (even if you don’t do anything but start it and close it.)
2.) Download and install XNA Game Studio 3.1, and it will add itself to your Visual C# installation.
3.) Start Visual C#, pick “New Project” from the File menu, and make a new “Windows Game (3.1)”. Don’t forget to pick a folder you can find, and name it something you can recognize.
New XNA Project4.) Now we’re back at funny looking code (Your mileage may vary – I have a custom color scheme installed after seeing Jeff Atwood’s post on color schemes) – Save it. You know the drill.
Installing XNA Step 2

5.) In the “Debug” menu, pick “Start Debugging” – or just hit F5. Try to get in the habit of keyboard shortcuts – they save colossal amounts of time. All the program does so far is display a Cornflower Blue window and wait for you to close it, but it’s more program than we had a half hour ago, and more colorful than our Allegro cousin. We have a starting point!

Afterword:

Either path you took, you now have a starter project that doesn’t do much but wait for input and display a large colorful rectangle. Even if you have no idea what’s going on in the code shown, we’ll come back to it step by step and piece by piece, until it makes a little more sense. In the meanwhile, have you been Making Your Sandwich – I mean, working on your Space Invaders design document?

Leave a Reply