Skip to content Skip to sidebar Skip to footer

Powerups Not Colliding With Player (pygame)

I've been having trouble getting my powerups to disappear upon colliding with the player character. I've been able to get powerups to drop upon killing enemies with bullets, but I

Solution 1:

You are not setting the self.rect.x and self.rect.y on your player only the self.x and self.y, so the collision detection is using (0, 0) as its position.

In the pygame docs

spritecollide(sprite, group, dokill, collided = None) -> Sprite_list

Return a list containing all Sprites in a Group that intersect with another Sprite. Intersection is determined by comparing the Sprite.rect attribute of each Sprite.

Post a Comment for "Powerups Not Colliding With Player (pygame)"