Im my pygame game I am comparing this distance between 2 objects, and trying to "pop" them when they are too close together, but sometimes, (seemingly random) the code crashes upon collision. if someone could help me, that would be nice.
the error message is:
IndexError: list index out of range
relevant code:
for i in reversed(range(len(birdies))):
birdies[i].moveBird()
birdies[i].calcSpeeds()
birdies[i].drawEnemyBird()
for j in reversed(range(len(shots))):
if distance(birdies[i].x, birdies[i].y, shots[j].x, shots[j].y) < shots[j].rad/2 + birdies[i].width/2:
birdies.pop(i)
shots.pop(j)