Hello! I need to develop a function to detect collision between one spaceship (given like [ [position x; position y], velocity, radius]) and an undefined number of stars ([position x; position y], mass, radius]]) as part of a homework. Each one of them has a radius and a center, I wrote like this:
def collisiondetection(Spaceship, Stars):
SpaceshipInitialPlace = Spaceship[0]
RadiusSpaceship = Spaceship[2]
Collision = false
for Star in Stars:
StarPosition = Star[0]
StarRadius = Star[2]
if distance*(StarPosition, SpaceshipInitialPlace) <= RadiusSpaceship + StarRadius:
Collision - true
return (Collision)
However, it stops when I give a list with more than one star, like collisiondetection([[-800, 0], [9, 4], 70], [[[0, 0], 8e+22, 10], [[-900, 10], 5e+21, 60]]), it only reads the first star, while I need it to read all of them.
Thanks!
*I've previously defined distance and it works