Hello, I am trying to create a game. i have a class that draw triangles and i select them through a circle that is inside. The problem is when I have several figures, the circles overlap and I cannot select them one by one.
I want to know if there is a way to pass one figure over another and not “pick it up”
this is my code

Your function to detect if the mouse is in the circle works but you are drawing your circle with the radius for the x and y size in the ellipse() function. Those parameters are the diameter of the ellipse so use : ellipse(xpos, ypos, radius * 2, radius * 2);

Since boolean select() is a method of the class Triangle, you have direct access to the member variables of the class so you don’t need to pass xpos to ypos to the select and overcircle methods. Instead use directly xpos and ypos.

There is no point of doing this :

if (distance <= r) {
return true;
}
return false;

Because if distance <= r is true then you return true and if it’s false, you return false. You can just return (distance <= r);.

You should consider using the mousePressed() or the mouseDragged() functions to check when the user is pressing the mouse because on your code, if you drag the mouse too much, it’s missing the ellipse.