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

Re: [pygame] collision



Since you're already using sprites, the easiest way to test for a collision between the ball and bar would be to use the pygame.sprite.spritecollide function.

Put this in your while loop somewhere:

if pygame.sprite.spritecollide (ball, [bar], False):
    print "ball hit bar"

You have to put the second argument to the function in brackets because it expects a list of some sort. Now you can simply change the print to something like reversing the balls speed.