# How to draw a circle that is around an object and becomes smaller if the player enters it

I'm making a game in Java w/ slick and lwjgl and right now I want to do the following: draw a circle, that is drawn around an object with a radius of e.g. 75. I want the object to be IN THE MIDDLE of that circle. That is easy but I also want the circle to become smaller when the player enters it. Basically this is an example:

Players x is 100

The OBJECT'S x is 300

The circle's x is (300-75 == 225),(object's x - radius) and its width is radius*2, so 150

When the player is inside of the circle (players x > circles x; e.g. 230 > 225) then I want the RADIUS of the circle to shrink to 70 (75 - (230 - 225), or, radius - (palyers x - circles x)), and after the circle shrank it should still be perfectly around the object from before. (AND BTW I didn't mention the y variable because it's self-explanatory after I figure out the x) Can anyone explain me the maths behind it please. Thank you

• I don't understand. Does the circle have a fixed size until the player enters it? Does the circle shrink proportionally with the player's distance from the middle? What happens if the player gets to the middle—does it disappear? A picture would be helpful. – Anko Nov 7 '15 at 21:28
• Yes, the circle stays the same unti the player enters it, and then it shrinks proportionally by how far the player has enterd it. When the player is at the middle it should just be very small. I am using this circle to see if the player is close to a 'spike' and the closer he is to it the faster your health will drop. – Ivan Jerza Nov 8 '15 at 8:42

sqrt((100 - x)^2 + (120 - y)^2)

d = sqrt((100 - x)^2 + (120 - y)^2) - 25 - 9