# Rect following mouseX slowing speed problem

**URL:** <https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491>\
**Category:** Coding Questions\
**Created:** [September 28, 2021, 8:46pm UTC](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491 "2021-09-28T20:46:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenga123456](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Post date:** [September 28, 2021, 8:46pm UTC](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491/1 "2021-09-28T20:46:11Z")

</div>

I have tried changing this line -xVel = xVel\*0,999- here but I can’t find a way to make the ellipse more gradually lose speed. Here is my code

```auto
float ellipseXPos = 300;
float ellipseYPos = 300;

float xVel = 1;
float yVel = 1;

void setup() {
	size(600, 600);
	background(0);
	frameRate(30);
}

void draw() {
	
	background(0)
	ellipseXPos = ellipseXPos + xVel;		
	ellipse(ellipseXPos, ellipseYPos, 40, 40);
	xVel = xVel*0,999;

	if (mousePressed) {
		xVel = mouseX/10-ellipseXPos/10;
		print(xVel);
	}
	}

```

---

<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:** [September 28, 2021, 9:03pm UTC](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491/2 "2021-09-28T21:03:30Z")

</div>

like this…?

```auto

float ellipseXPos = 300;
float ellipseYPos = 300;

float xVel = 0;
float yVel = 0;

void setup() {
  size(600, 600);
  background(0);
  frameRate(30);
}

void draw() {
  background(0);
  ellipseXPos = ellipseXPos + xVel;    
  ellipse(ellipseXPos, ellipseYPos, 40, 40);

  xVel = xVel * 0.8999;

  if (mousePressed) {
    xVel = (float) mouseX/10.0-ellipseXPos/10.0;
    print(xVel);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Kenga123456](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Post date:** [September 28, 2021, 9:05pm UTC](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491/3 "2021-09-28T21:05:30Z")

</div>

Yup thanks! I don’t know how I did not see that.
