[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Rect collision by direction



Not sure if this is relevant or helpful, but what I usually do is calculate the
amount of overlap between the rectangles in all directions. The direction with
the least overlap is the one you should "pop-back".

Chris.

On Sun, Jun 07, 2009 at 09:09:43AM -0500, pymike wrote:
> On Sun, Jun 7, 2009 at 1:24 AM, Skizzaltix <waterflight@xxxxxxxxxxxxx>wrote:
> 
> > Thanks! It's working like charm now. Thanks, everyone!
> > --Skizzaltix
> >
> >
> > Brian Song wrote:
> >
> >> Diagonal collision detection seems to get a lot of people including myself
> >> the first time. If you haven't fixed it yet, the remedy will most likely
> >> require you to do 2 collision detections instead 1. Without looking at your
> >> code, I'm gonna assume your doing collision detection on both axis at once.
> >> What you should do instead is first check for collision on one axis, figure
> >> out whats happening, then do a collision detection for the other axis.
> >>
> >
> >
> Yup, that's what the tutorial I posted shows. :)
> 
> -- 
> - pymike
-------------------
http://mccormick.cx