Posts categorized “Uncategorized”.

The Top 10 Pygame Tutorials

I’ve scoured the web for some decent tutorials for Pygame, one of the best game engines for Python out there. Here’s what I’ve found, ordered by (in my opinion) quality. Perhaps the most comprehensive guide to Pygame would be the Pygame documentation itself, or Beginning Game Development with Python and Pygame: From Novice to Professional by Will McGuan.

1. Eli Bendersky’s website: Writing a game in Python with Pygame

Possibly the best Pygame tutorial on the web. The game example he covers is original and touches on many different concepts. The writing is concise and to the point.

Part I
Part II
Part III
Part IV

2. Invent Your Own Computer Games with Python by Al Sweigart

This is my own tutorial for Pygame. The first three chapters cover the basics of Pygame’s features, and the fourth chapter details the entire source code to a simple “Dodger” game.

Chapter 17 – Graphics and Animation
Chapter 18 – Collision Detection and Input
Chapter 19 – Sound and Images
Chapter 20 – The “Dodger” Game

More… »

Gorilla.py: A Remake of Gorilla.bas

Source code: gorilla.py

An entire generation of people remember the Gorilla.BAS game that came with Qbasic, where gorillas on top of buildings threw exploding bananas at each other. This is a Python remake of that game using the Pygame game engine, and is fairly heavily commented so you can explore the source. To play the game in your browser, there is also a Flash version of Gorilla.BAS.

My prime motivation behind creating this was to compare how much easier programming is today compared to a decade ago with Qbasic. Python makes a great first language to learn, and I have argued before how Python is the New BASIC. (The second motivation was to promote my (free) book on Python games and get people back into programming. :) )

To demonstrate: not counting blank lines and comments (and the multiline strings for the graphics), Qbasic’s gorillas.bas is 784 lines of code while Python’s gorillas.py is 544 lines of code (about 30% less code!) Every programmer’s mileage may vary, but I think that makes a good case for Python’s syntax being expressive and simple.

This game was written by the author of “Invent Your Own Computer Games with Python”, a free book available under a Creative Commons license at http://inventwithpython.com. The book teaches Python to kid and adult beginners by giving the source code to several different games (along the lines of gorilla.py) and explaining them line by line. Learning to program this way is fun!

A print copy of the book is available (with free shipping) on Amazon.com for $25.

Attitudes on Programming for Kids: “They Need Blood Exploding Onto Their Faces Just to Keep Them From Yawning”

Wrote a new blog post on our attitudes towards kids and programming on my Coffeeghost blog.