hi, I haven't had a chance to look over the code yet...
However these are my thoughts: - a generic method which does more efficient collision detection + response for multiple sprites would be good. - a new top level module for it would be bad. It should probably be incorporated in the sprite module. - the examples/testsprite.py example would be the place to test out the api. It could then even compare performance to the naive approach used there. cheers, On Jan 7, 2008 6:48 PM, <[EMAIL PROTECTED]> wrote: > So unfortunately, I don't have time this weekend or next to get the work > done on the Collision Resolver that I'd hoped. So I'm making a call out to > the community: if anyone is interested in this module and its inclusion into > Pygame, and wants to fill in the missing docstrings and write up some unit > tests, please get in touch with me (off-list). I'm open to attaching a > monetary award/bounty. > > -sjbrown > > > > Hi all. > > > > Here's a "collision resolver" module I've been working on. > > > > A common problem in 2D games is trying to move a sprite in a direction > > (deltaX, deltaY) and then discovering that there is a solid object in the > > new position it wants to occupy, so you have to move it back to the edge of > > that solid object. > > > > Further complicating matters, just checking the end position is sometimes > > not enough. When a rectangle moves it sweeps through a hexagonal shape, and > > there might be solid objects that collide with this "sweep hexagon" that > > don't collide with the end position. This issue is more pronounced the > > bigger (deltaX, deltaY) gets. > > > > An even further complication: if you displace the rect due to a collision > > inside the sweep hexagon, it may then collide with a new solid object that > > lies outside the original sweep hexagon. > > > > This module provides a function that you can call, resolve_collisions() that > > will sort all this mess out for you. > > > > I think this is a general enough problem in 2D games that the resolver > > function be considered for inclusion in pygame itself. > > > > I have included a program that demonstrates what it does. Just run: > > > > python collision_resolver_example.py > > > > options are printed to the terminal. > > > > -sjbrown > > > > >
