Hi xhqecho,
Can you please format your code? It is all explained in this thread: Guidelines—Tips on Asking Questions
The problem is that you are using a for loop to draw your shape but you are not having one to check the distance. So you are checking the distance with the last x value the for loop is giving you.
Consider using another loop to check the distance for each one of your circle.