In your code, it reads:
(Pseudo Code:)
On mouse click: If the mouse has been clicked twenty times, draw a circle.
Otherwise, set the mouse to be clicked 0 times.
I hope you can see the error here. The mouse variable is constantly reset to 0, and never reaches twenty. A better way to do this would be to:
int mouseClicks = 0; //Our initial variable. This stores all of our clicks.
void mouseClicked(){ //Our click function. I like to use mouseReleased in my programs, but it's up to you.
if(mouseClicks == 20){ //If it's twenty run this line:
//Your ellipse/circle
} else {
mouseClicks++; //Increases the click count by one ever click.
}
}
Actually, after reading this; maybe you should do something closer to this:
(More Pseudo Code:)
Every time you click a mouse, increase the times it clicked by 1. If it's greater than twenty, ever time we click, draw a circle.
And the actual code would look like:
ArrayList<int> x = new ArrayList<int>(); //Create an arraylist that continues to be able to grow.
ArrayList<int> y = new ArrayList<int>(); //I probably would use a PVector, but hey.
int clicks = 0; //Stores how many times we've clicked.
void mouseClicked(){ //Our click function.
if(clicks >= 20){ //If our click count is < 20, do nothing but increase our click count.
x.add(mouseX); //If it's bigger than twenty, store the mouse positions in an arraylist
y.add(mouseY); //I'm doing an arraylist so that I don't have to worry about running out of space in the list.
} else{
clicks++; //Just increase our click count.
}
}
void draw(){ //Begin our draw loop
background(255); //Our background so that it wipes.
for(int i : x){ //For all X values in our list, store them as variable: i
for(int j : y){ //For all Y values in our list, store them as variable: j
circle(i, j); //Finally, draw each ellipse/circle at those locations.
}
}
}