0

When my vehicles eat, I can only get one sprite to update its health and color, I tried looping through the sprites but that still doesn't work. Honestly, I'm thinking of refactoring the entire program and not using sprites at all. For testing purposes I have two vehicles, one updates the other does not. When the one that does not update eats, the other's health updates.

for sprite in players:
    collisions = pg.sprite.groupcollide(players, mobs, False, True)
    if collisions:
        for collision in collisions:
    
            new_food()
            setattr(sprite, 'health', sprite.health + 10)
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Dave
  • 3
  • 4
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 01 '22 at 14:47

1 Answers1

0

I solved the issue. I was using groupcollide when what I needed was spritecollide, still not satisfied with the reults though

Dave
  • 3
  • 4