# Spawn a shape or object whenever the initial object reaches a specific locaton

**URL:** <https://discourse.processing.org/t/spawn-a-shape-or-object-whenever-the-initial-object-reaches-a-specific-locaton/18737>\
**Category:** Beginners\
**Created:** [March 17, 2020, 3:33pm UTC](https://discourse.processing.org/t/spawn-a-shape-or-object-whenever-the-initial-object-reaches-a-specific-locaton/18737 "2020-03-17T15:33:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NotConsumable](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NotConsumable](https://discourse.processing.org/u/NotConsumable)\
**Post date:** [March 17, 2020, 3:33pm UTC](https://discourse.processing.org/t/spawn-a-shape-or-object-whenever-the-initial-object-reaches-a-specific-locaton/18737/1 "2020-03-17T15:33:33Z")

</div>

I have an ellipse moving across the screen with

```auto
ellipse(redBallX,redBallY,40,40);
redBallX = redBallX +1;

```

I was wondering how I would make it so that when the X value of the ball hits 50 pixels across the screen as the initial value of redBallX = 0 so when the value reaches 50 it spawns in the exact same object?

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [March 17, 2020, 3:43pm UTC](https://discourse.processing.org/t/spawn-a-shape-or-object-whenever-the-initial-object-reaches-a-specific-locaton/18737/2 "2020-03-17T15:43:49Z")

</div>

Hello @NotConsumable,

Please do not start a new thread to ask follow-up questions:

> [@Move an ellipse](https://discourse.processing.org/t/move-an-ellipse/18717):
>
> I was wondering how I would make an ellipse continuously move down a x axis while maintaining it’s Y position, in better terms I am trying to make an ellipse start at one end of the canvas and continue down to the other side while spawning a new ellipse that is the exact same and movement pattern every 50 or so pixels apart from each other

---

<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:** [March 17, 2020, 3:45pm UTC](https://discourse.processing.org/t/spawn-a-shape-or-object-whenever-the-initial-object-reaches-a-specific-locaton/18737/3 "2020-03-17T15:45:20Z")

</div>

This reminds me of my reply to your last post. Why do you start a new discussion?`  
Please post your entire code (of program 1 and of program 2)

in program 1 still  
within `draw()` function

```auto
ellipse(redBallX,redBallY,40,40);
redBallX = redBallX +3; // FASTER NOW 

if(redBallX>=50) 
     redBallX = 20;

```

Chrisir
