Skip to content

Teaching games with Pygame

2009 June 10
by Hélène Martin

I’m ambivalent about the place of games in programming/computer science courses.  Some research claims it increases interest and retention, other claims it alienates non-gaming students.  I personally would have avoided an introductory course centered on game programming and I worry that women are disproportionately turned off by games.  That being said, I’m willing to concede that the number of students hooked by games may outweigh those it alienates…

Even then, though, I worry about the educational content.  There are a lot of very interesting problems in game AI or graphics, but that’s far from introductory material.  Even basic games require complicated ideas including game loops (yes, that’s hard for intro students), interrupts and graphics in order to be compelling, especially for kids who were born into fancy 3D games.

When trying to teach games, especially when attempting to cater to the gamer types who like fancy things right away, I think it’s easy to slip into “tutorial-mode.”  Tutorials are great for learning some quick skills, but I don’t believe they can convey the intellectual content an introductory programming course should provide.  It’s too easy for students to start simply pattern-matching without really understanding what they’re doing.  With this kind of approach, it’s unclear to me how students will be able to turn around and then build non-game programs.  Truly understanding the abstractions programming languages make takes incremental steps, time and practice.

Here’s the reality: a number of students in the Python class I work with had been asking how to build games and it seemed like a reasonable way to end the year.  By now, they have a reasonable grasp of basic programming constructs and are comfortable in Python so pygame seemed like a good fit.

I’m not sure I quite avoided the tutorial trap, but I think that given their existing understanding, that’s probably ok.  The real value to having them work with pygame, I think, is that they have an opportunity to gain experience referring to documentation and sample code in order to work in an existing programming environment.  For example, they (should) understand classes and objects, so it’s a good opportunity to practice using those concepts.

The slides I “lectured” from — we went through each concept and practiced together (stolen/adapted from ones I used at UW):

ppt16x16 HeleneMartin-Python-Pygame-Intro.ppt
pdf16x16 HeleneMartin-Python-Pygame-Intro.pdf

The files I created with them in class:

pygame16x16 template.py
pygame16x16 class_example.py
png16x16 beach_ball.png

2 Responses leave one →
  1. July 25, 2009

    Dear Helen

    I came across your blog about teaching Pygame and found it very interesting. I am an amateur game designer/developer and I am writing an article on Pygame. Do you have any published materials on teaching Pygame in schools/colleges etc that I may use as a cited reference to my article ? or otherwise if you may provide me with some information and statistics as to (1) how did the innovation hit you and/or (2) how your students welcomed Pygame and/or (3) why Pygame ? , it may be very useful to me.

    I look forward to your reply

    Kind regards

    Arkapravo

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS