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

I have an ellipse moving across the screen with

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?

1 Like

Hello @NotConsumable,

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

1 Like

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

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

if(redBallX>=50) 
     redBallX = 20;

Chrisir

2 Likes