Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem using spritegroups in pygame. In my situation I have 2 spritegroups, one for humans, one for "infected". A human is represented by a blue circle:

image = pygame.Surface((32,32))
image = image.convert()

An infected by a red one (same code, different color).

I update my spritegroups as follows:


 self.infected.draw(self.screen) is defined: = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT)),255,255))

This all works, except that when a red circle overlaps with a blue one, you can see the white corners of the bounding box around the actual circle. Within a spritegroup it works, using the set_colorkey function. This does not happen with overlapping blue circles or overlapping red circles.

I tried adding a colorkey to but that did not work. Same for adding a colorkey to self.screen.

share|improve this question
Can you post a screenshot? – muhuk Feb 2 '12 at 1:58

This is not the problem with colorkey. When you clear the sprites from the second group, you erase parts of the sprites from the first group that were already drawn. To fix it, change the order of clearing and drawing:



share|improve this answer

Im new enough to python so I may be completely wrong but would it work if you put in pygame.display.flip()

Thats what I have in my game after it is drawn and updated on the screen?

share|improve this answer
Nah, is not necessary here :-). (It's not all my code by the way ;)) – Fristi Feb 1 '12 at 18:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.