February 4th, 2013, 07:27 AM
Pygame collision detection
hi everyone, I am working on a quite simple game in pygame.
it involves a ball which you control jumping over a whole load of other balls in very basic terms.
I am trying to make the screen go black when your character hits another ball
I am using this line:
in my while loop to detect the collision but whenever I play the game the screen goes black instantly
if pygame.sprite.spritecollide(myPlayer, ballGroup, False):
I have done some print checks and it definetly thinks the collision has happend when it hasn't
I have also tried things like:
but I just get errors.
thanks in advance
February 4th, 2013, 04:31 PM
edit: Pretty sure my answer was incorrect after looking over it, so I deleted the bad advice. I will have to download pygame and experiment.
February 5th, 2013, 08:32 AM
well... I dont think it was completely wrong. I tried it and though I didn't
get a black screen the colision didn't seem to detect, the balls just went past it. Anyway thanks for trying maybe someone else can build on it.
for anyone else looking ar this the code which I tried was
if pygame.spritecollision(myPlayer, ballGroup, True):