# Mouse Clicked function and storing variables

**URL:** https://discourse.processing.org/t/mouse-clicked-function-and-storing-variables/11823
**Category:** Coding Questions
**Created:** [June 4, 2019, 3:38am UTC](https://discourse.processing.org/t/mouse-clicked-function-and-storing-variables/11823 "2019-06-04T03:38:29Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)
#### Post date: [June 4, 2019, 5:43am UTC](https://discourse.processing.org/t/mouse-clicked-function-and-storing-variables/11823/2 "2019-06-04T05:43:58Z")

</div>

Here is a few things you might find helpful:

- [Easing Example](https://processing.org/examples/easing.html)
- ArrayList - [Documentation](https://processing.org/reference/ArrayList.html) - [Video Tutorial by Dan Shiffman](https://www.youtube.com/watch?v=HnSJZ4qTcwY&list=PLRqwX-V7Uu6Z9hI4mSgx2FlE5w8zvjmEy&index=2)
- PVector - [Documentation](https://processing.org/reference/PVector.html) - [Video Tutorial by Dan Shiffman](https://www.youtube.com/watch?v=7nTLzLf7jUg&list=PLRqwX-V7Uu6ZwSmtE13iJBcoI-r4y7iEc&index=2)

Here’s what I would try:

Create an arraylist and in setup add a random (or `mouseX` and `mouseY`) location to it.

Use the mouse clicked function add a location to the end of an arraylist.

Then in draw you have the object move towards the first thing in the arraylist. And If the object is within a certain distance (look into [`dist()`](https://processing.org/reference/dist_.html)) and the `arraylist.size()` is greater than 1 remove the first element in the arraylist.

Hope that make sense and is helpful.

---

_[View the full topic](https://discourse.processing.org/t/mouse-clicked-function-and-storing-variables/11823)._
