Introduction to Game Development with Pygame

(back to P.E.T.)

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


In effort to promote this J-term course, these video clips were shown in 2012 to the General Physics and Cosmic Universe classes in Olin Hall at Gustavus Adolphus. 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

This demo shows a laser box cutter based on the ray casting feature of Box2D. Polygons are segmented based on the intersection points of the ray cast.

(back to P.E.T.)