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

Re: [pygame] Rect collision by direction



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, though, and I'll see if I can work this out--I may end up reworking the way I'm handling walls. Otherwise, if someone knows of a solution, I'd love to hear it!
Thanks!
--Skizzaltix

pymike wrote:
Hi, I wrote a tutorial on this:
http://pymike.pynguins.com/?page=tutorials&id=1 <http://pymike.pynguins.com/?page=tutorials&id=1>

HTH

On Sat, Jun 6, 2009 at 1:33 PM, Skizzaltix <waterflight@xxxxxxxxxxxxx <mailto:waterflight@xxxxxxxxxxxxx>> wrote:

    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 the character is moving
    slightly downwards, he/she will continue moving down, but stop
    moving to the left.
    I'm sure there's some simple solution to this, which I have been
    missing entirely.
    Thanks!
    --Skizzaltix




--
- pymike