Take the 2-minute tour ×  I making a small program to animate
the astar algorithm. If you look at the image, there are lots of
yellow cars moving around. Those can collide at any moment,
could be just one or all of them could just stupidly crash into
each other.  How do I detect all of those collisions? How do I
find out which specific car has crash into which other car?  I
understand that pygame has collision function, but it only
detects one collision at a time and I'd have to specify which
sprites.  Right now I am just trying to iterate through each
sprite to see if there is collision:  for car1 in carlist:
for car2 in carlist:         collide(car1, car2);  This can't be
the proper way to do it, if the car list goes to a huge number,
a double loop will be too slow.  enter image description here
share|improve this question add comment  2 Answers  up vote 3
down vote accepted  There is no 'proper' way, just different
approaches that vary from simple-but-slow to complex-but-fast.
You can stick with that