Introduction to Game Development with Pygame

(back to P.E.T.)

PHY-109-001, #28875, Python 2D Game Prog, J-term 2013.   

I showed these video clips this morning (Fri October 26, 2012) to the General Physics and Cosmic Universe classes in Olin. They're posted here to give others a sense of what can be done with Pygame. Here are links to the flyer, a one-pager, course syllabus, and the physics engine tutorial.

Pygame 1D Physics Air Track

This first clip demonstrates 1D collision detection, mouse-event interactions and modeling of forces by gravity and mouse tethers. We use Pygame's capabilities to quickly draw polygons to the screen and listen for keyboard and mouse events. Frame rates of 400 per second are easily seen on a basic computer. (The YouTube videos don't really do these demos justice. Stop by my office to see them live, high resolution, and creamy smooth. I'll let you shoot the guns...)



Pygame 2D Physics Air Table

Much of the algorithmic content of the 1D exercise is extended here with a 2D vector class. Also object-object forces as modeled by springs and dampers are added. Collision detection and penetration corrections are developed for spherical shapes. Limitation of this simple home-brew physics engine are demonstrated with progressively smaller diameter ball-settling tests. Notice the popcorn effect of the smaller balls as they try to settle three balls deep. Finally a 2D grid of balls and springs shows how this basic physics engine can yield realistic results for non-spherical object collisions with walls (looks like a square piece of Jello).



Pybox2d Guns and Stacking

Here I'm using the pybox2d port of the Box2D physics engine (of Angry Birds fame) to do the computational heavy lifting. This illustrates Box2D's capabilities for general modeling of non-spherical objects. This includes proper handling of contact forces, stacking, and settling behaviors.



Pybox2d Vertical Bullet Stream and Mouse Gun

A short clip showing a vertical stream of rectangles collapsing onto itself. It acts like a fluid. Also a brief demo of a cursor gun.



Pybox2d Box Cutter

Demo of a laser box cutter.


(back to P.E.T.)