Pygame - Different sided collision question!

Posted by Alex Lockwood on Stack Overflow See other posts from Stack Overflow or by Alex Lockwood
Published on 2009-04-30T23:58:46Z Indexed on 2010/06/08 10:02 UTC
Read the original article Hit count: 208

Filed under:
|

Hi there everyone!
I'm making a Pygame of, basically, "Breakout".
I'm using collisions, and want a simple way to have different bounce effects of the different sides of one rectangle.
What I currently have for the ball-to-bat collision is this:
"dot" = ball; "bat" = bat; so you all understand.

if dot.rect.colliderect(bat.rect):<br>
 dot.dy *= -1

I'd like something that interacts with each side, so could reverse the self.dx value of the ball when it hits the side of the bat, and only reversing the self.dy value when it strikes the top.

Thanks!!! :D

© Stack Overflow or respective owner

Related posts about collision-detection

Related posts about pygame