My crash course in PyGame

After reading about the PyWeek Python Game Programming Challenge, I decided to take a closer look at PyGame:

Pygame is a set of Python modules designed for writing games. It is written on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system.

So tonight I installed PyGame on my Windows box and fired up Komodo


PyGame has a couple of dependencies which, while automatic on Linux, have to be installed manually in Windows: Numeric, Numarray, PIL, PyOpenGL. Thankfullly they each had installers for win32, making it pretty easy. A quick test to confirm everything was working and I was set.

import pygame from pygame.locals import *

No errors while trying to import the libraries. Looks good.

The PyGame website has links to a few tutorials including A Newbie Guide to PyGame, An Introduction to Python Game Programming. There are also a few tutorials included in the general documentation.

I was able to quickly work through the Pygame Introduction and Import and Initialize and ended up with a working little “game” if you can call it that. A simple 320×240 window with a bouncing Doom marine with speed controlled by the up and down arrows on the keyboard:

Bouncing marine

Heh. Granted, it’s not much. But considering I’ve never created a graphical app in any language until tonight, it was rather satisfying to see how easy this was!

Registration for PyWeek 2 doesn’t start until February 24 and the contest on March 26. It think it would be really cool if I could get enough PyGame experience under my belt between now and then to be able to register. I can’t imagine I’d have any chance of winning, but I’d be happy just to enter a working game. Might be fun.

Update: Checked out some of the games made with PyGame, and Cuzco’s Goat Bloat Game is far more fun than it should be. :)

2 Responses to “My crash course in PyGame”

  1. import this. » Blog Archive » A little PyGame progress Says:

    [...] « My crash course in PyGame [...]

  2. import this. » Blog Archive » PyWeek 2 registration now open Says:

    [...] Although I’ve thought about it, I just don’t think I’m comfortable enough with PyGame to enter this time around. Maybe I’ll try PyWeek 3 if they have one. [...]

Leave a Reply