# Hey! I need help with figuring out, how to make this outcome possible?

Hey! I need help with figuring out, how to make this outcome possible? Create a program that allows the user to click 20 times on the screen. Once the 20th click has been pressed, circles will appear on the run window where the user clicked.

Where should I start off?

please format code with </> button * homework policy * asking questions

Check out arraysâ€¦ or ArrayListâ€¦

collect the mouse pressings, store them,
And display them when counter is 20

First of all, you need a counter. I suggest using an integer to store it. Upon every click, increase it by 1 and add the position of the mouse into an array (can use x = new int[]; y = new int[] OR PVector pos = new PVector[] OR int pos[][] = new int[][2]; //[i][0] - x position [i][1] - y position OR you can use ArrayLists that are flexible in size).

In draw() you just add something like

``````if(counter>=20) {
//run through the array and display the circles there. I suggest using a for-loop
noLoop(); //optional to pause the program.
}
``````
3 Likes

Check out the function mousePressed () much better than the variable mousePressed which is written without the brackets ().
See reference on website

In the function say

``````void mousePressed (){
xArray[counter]=mouseX;
yArrayâ€¦â€¦Y;
counter++;
}
``````

before setup() int counter ;

1 Like

Hello,

You listed:

``````x = new int[];
y = new int[] ;

PVector pos = new PVector[];

int pos[][] = new int[][2]; // [i][0] is x position,  [i][1] is y position

``````

`````` int pos[] = new int[];  //[i] is x position,  [i+1] is y position
`:)`