Skip to: Site menu | Main content

CS4HS 2011: Pygame Workshop

Hi everyone! Welcome to the Pygame workshop. This is a follow-up to my Python workshop in the summer; if you were with me in the summer, you'll have the required background to jump in here. Actually, as long as you know the basics of Python, you should be OK. If you want to learn Pygame but you haven't done any Python, you might like to visit the website of the previous workshop.

I've set up this webpage to help you prepare your laptop for the workshop, and to hold the workshop materials and resources once we're finished. If you have any questions, please feel free to contact me!

We'll start with a quick (and I do mean quick) review of Python basics, and then spend some time on intermediate Python... most notably, how to do OOP in Python. OOP is important because it works nicely as a design technique for games. So after we're finished with the OOP basics (classes, inheritance, constructors, etc.), we'll spend our remaining time on Pygame.

What's Pygame? Pygame is a Python library for developing games. Trust me: it's extremely cool. We'll start from scratch and introduce all concepts required to make a 2D game: sprites, sounds, movement, collision detection, fonts, drawing shapes, keyboard input, frame rate, and so on. We'll finish up by examining a completed Pygame game that I wrote to demonstrate all of these concepts.

Preparation

I'm going to ask that you bring your own laptop to the workshop, just as I did in the summer. If you don't have an available laptop, please let me know!

It's required that you have Python 2.5 or 2.6 installed, along with Numeric and Pygame. You'll also want a text editor available, and you should be able to run Python programs from the commandline. For all of this, please see the previous workshop website for instructions.

Testing

Once everything is installed, let's test with a simple hello world program that uses Pygame. Download this hello.py, put it in a directory on your computer, and make sure you can run it using Python by typing python hello.py. You should see a screen that says Hello World. If you get an error, please let me know... it's important that you have Pygame up and running so we can get out of the gate quickly at the workshop.

Materials

  • Pygame Workshop Materials. This is a zip file containing all of the resources we'll use during the workshop. It contains many example Python files, as well as a pdf of my slides. There is also a complete Pygame game (scroll.py) that uses everything we'll learn in the workshop. Please extract this archive into a new directory and make sure you can run scroll.py. I kindly ask that you don't publicly distribute these files, since they are the basis of several assignment ideas. But by all means use whatever you like with colleagues and students!

Done!

Alright, let's do this. Game on!