Code for the example in chapter 7 from the "Beginning Game Development with Python and Pygame"