Logic on making a circle disappear when clicked and drawing another circle at the same time

I recommend you look at screenX and implement it

for p5

see Mouse interaction with 3D objects / objects on 3D plane - #2 by Chrisir

In processing JAVA flavor you can say

theX=screenX (.........
theY=screenY (.........

and later


if(dist(mouseX,mouseY,theX,theY)<40) {
     // hit
}