pygame is
Simple DirectMedia Layer is
Site Swing


Chandler Armstrong (omnirizon)



Much thanks to pymike and saluk for the Retro Game Library. The 'seperating axis theorem' function was sourced from this library (with some minor modifications)

vizier: a package for managing sprites and the screen, provides scrolling, scaling, and collision response.

xrects: a package for polygons. uses the pygame rect as the axis aligned bounding box (AABB), and subclasses the rect to add the polygon object and methods for collision detection.

Add the files in the zip to your python path. The files include the 'glyph' module which is used in the demo. glyph is a module for handling text. View the demo by running ''. Once the demo is running, press and hold space bar to let the sprites be updated. Release the space bar to pause everything and get a chance to look around. Clicking on sprites will display some information about them (it was stuff I was using to debug a physics system). The sprite update does use some physics. Feel free to replace the sprite object with one of your own.


Home Page:


click to view original size account Comments

If you wish to leave a comment with your account, please sign in first.

December 15, 2010 10:45pm - Gummbum - nickname: (gummbum)
Aha. I see your

December 12, 2010 1:21pm - Gummbum - nickname: (gummbum)
You're alive! :)

I sent a message to your sourceforge mailbox a few months back; I guessed it got et or you don't check it often. I've been working on my own world/map/camera implementation using pymunk for the physics--just for it's polygon and line collision detection. It hasn't been going as well as I liked, and I'm looking forward to seeing your progress.

I agree with your take on the polygon origins. I just wanted to point out for the benefit of others that it was different from pygame's rects in that respect.

Also, I saw your query another project about game clocks. I recently did some study which resulted in a cookbook recipe. Almost as easy as pygame's Clock, quite accurate, and adds independent render frames and interpolation. See

December 12, 2010 12:53am - Chandler Armstrong - nickname: (omnirizon)

thanks for your comments. I was not aware of those gotchas! I'll check them out and see if the class can be modified to behave more like a rect.

I think I designated the center, rather than the topleft of the bounding rect, as the origin because it is easier to imagine what points you would need to obtain a desired polygon that way.

I definitely need to add more documentation. that's a goal for this winter break.
September 25, 2010 1:58pm - Gummbum - nickname: (gummbum) - 4/5
This is great, Chandler. It is exactly what I've been scouring the Internet for. =)

I just wish for better documentation! The inline comments are not enough to enable me to wring more than the basics out of the math voodoo in xrects. Some features I think I may never be able to figure out, like 1) the purpose of the projections returned by xrect.CollisionDetector.sat, and how to use them; and 2) how to rotate a polygon and test the rotated shape for collision.

I discovered some things that new users of this need to be aware of.

Because xrect.Polygon subclasses pygame.Rect, I was tempted to use it in place of Rect. Unfortunately Pygame sometimes checks "==" or "is" Rect, rather than "isinstance", and blows up on xrect.Polygon. This means I need to maintain a Rect to feed Pygame and a Polygon to feed vizier-xrects. Not a major problem, as the model and view often use different structs anyway.

The other gotcha not documented is that the points argument of the Polygon constructor need to be designed with a 0,0 center or they don't turn out right. By contrast, Pygame shapes typically have 0,0 as the topleft coordinate.

With psyco this performs exceptionally well. Better documentation and a few demos that build up from xrect and vizier basics to the too-advanced-for-me would have motivated a 5-star rating.

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Jan 31, 2017

Jan 24, 2017

Jan 19, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)