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'm doing a game in which i have a ball which is controlled by the keyboard and the goal is to get is out of a maze without touching the walls.

I've added my ball sprite to GroupSprite

vehicle = pygame.sprite.GroupSingle(Vehicle(70,470))

since at the time, i thought that was the right way of doing it. However, i found that all the interaction always goes with the sprite directlly not with the GroupSingle. So I end with constantly accessing the sprite throug the GroupSingle.sprite:


Is there a reason why i shouldn't just remove 'GroupSingle' and define:

vehicle = Vehicle(70,470)
share|improve this question
up vote 1 down vote accepted

No. If you don't use any features of the Group, you can just stop using it.

However, nothing is stoping you from storing your player Sprite in a seperate field and using your GroupSingle for stuff like collision detection/drawing/updating if you maintain a list of SpriteGroups for example to have your code look more uniformly:

# initialize
vehicle = Vehicle(70,470)

vehicle_group     = pygame.sprite.GroupSingle(vehicle) # make it clear there's only one vehicle (player) by using GroupSingle
wall_group        = pygame.sprite.Group(YourWallSpritesOrSomething)
other_stuff_group = pygame.sprite.Group(OtherStuffSprites)
all_groups        = (vehicle_group, wall_group, other_stuff_group)

# drawing eveything, including player, walls, and stuff...
for g in all_groups:

# updating eveything, including player, walls, and stuff...
for g in all_groups:

# test if 'somesprite' collides with anything, including player:
if any(spritecollideany(somesprite, g) for g in all_groups):

# test if player (vehicle) hits a wall:
if spritecollideany(vehicle, wall_group):

But if the Sprite in your GroupSingle never changes, a regular Group would also be fine, but a GroupSingle would nonetheless make the fact clearer that there's always a single vehicle.

share|improve this answer

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.