PyCon 2012 PyGame Tutorial Setup for OS X Lion

PyCon US 2012 had a talk given by Katie Cunningham and Richard Jones entitled "Introduction to Game Development". I figured it would be fun to follow along.

I've written this guide as a quick-start to anyone who didn't attend but needs resources and tools setup to follow the tutorial. I'm doing this on OS X 10.7.x Lion, so your setup may vary. * Install PyGame stable 1.9 for your machine: http://www.pygame.org/download.shtml.

I was unable to get the version from PyPI to install, it complained about a missing setup.py file. I used the pre-built version that is designed to work for Apple-supplied Python on Lion. Run the setup .mpkg and test that it installed successfully:

1
2
3
4
5
6
$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import pygame

If you don't get any major complaints then continue with setup. I did notice that movie and scrap modules could not be loaded successfully upon executing import pygame; help(pygame) but haven't investigated further.

  1. Setup a directory to mess around in:
1
$ mkdir ~/gamedev
  1. Grab the sample files from Richard's BitBucket repo by either downloading them or cloning the repo if you have Mercurial installed:
1
~/gamedev$ hg clone https://bitbucket.org/r1chardj0n3s/pygame-tutorial
  1. Test that it's all working:
1
2
~/gamedev$ cd pygame-tutorial
~/gamedev/pygame-tutorial$ python 01-open-window.py
  1. If everything is configured correctly, you should see a window flash on the screen momentarily. You should now be ready to follow the tutorial, I'll update this post if I encounter any issues along the way.

If you have a cool game project in mind, why not sign up for PyWeek? It's a game development challenge in which participants develop a game in Python over a week by themselves or a team. Registration should be open in a couple of weeks.

Addendum

These are programs that Richard mentions in his presentation:

  • Tiled - Map editor which allows you to design and edit TMX files.
  • sfxr/cfxr - Sound file generator.