Re: [pygame] Rect collision by direction

2009-06-08 Thread Chris McCormick
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

Re: [pygame] Rect collision by direction

2009-06-07 Thread pymike
On Sun, Jun 7, 2009 at 1:24 AM, Skizzaltix waterfli...@speakeasy.netwrote: 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

[pygame] Rect collision by direction

2009-06-06 Thread Skizzaltix
Hello, I've been trying to find a way to, when detecting collisions between two sprites, determine which side of one sprite is colliding with the other. Basically, I want to make it so that when a character walking to the left collides with a block to his/her left, he/she stops moving, but if

Re: [pygame] Rect collision by direction

2009-06-06 Thread pymike
Hi, I wrote a tutorial on this: http://pymike.pynguins.com/?page=tutorialsid=1 HTH On Sat, Jun 6, 2009 at 1:33 PM, Skizzaltix waterfli...@speakeasy.netwrote: Hello, I've been trying to find a way to, when detecting collisions between two sprites, determine which side of one sprite is

Re: [pygame] Rect collision by direction

2009-06-06 Thread Skizzaltix
This works perfectly if the character is moving along only one axis, but if he/she is moving diagonally along a row of walls, both the colliding from the side and the colliding from the top if statements get triggered, and so the character ceases movement along both axes... Thanks for the help,

Re: [pygame] Rect collision by direction

2009-06-06 Thread Brian Song
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

Re: [pygame] Rect collision by direction

2009-06-06 Thread Skizzaltix
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