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

**URL:** https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282
**Category:** Coding Questions
**Tags:** homework
**Created:** [July 16, 2021, 5:29pm UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282 "2021-07-16T17:29:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bopStu77](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bopStu77](https://discourse.processing.org/u/bopStu77)
#### Post date: [July 16, 2021, 5:29pm UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282/1 "2021-07-16T17:29:20Z")

</div>

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](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 16, 2021, 7:37pm UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282/2 "2021-07-16T19:37:11Z")

</div>

Check out arrays… or ArrayList…

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

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [July 17, 2021, 9:36am UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282/3 "2021-07-17T09:36:52Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 17, 2021, 11:03am UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282/4 "2021-07-17T11:03:40Z")

</div>

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

```auto
void mousePressed (){
xArray[counter]=mouseX;
yArray……Y;
counter++;
}

```

before setup() int counter ;

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 24, 2021, 2:02am UTC](https://discourse.processing.org/t/hey-i-need-help-with-figuring-out-how-to-make-this-outcome-possible/31282/5 "2021-07-24T02:02:06Z")

</div>

Hello,

> [@CodeMasterX](#):
>
> 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).

You listed:

```auto
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

```

Adding this to the list:

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

```

`:)`
