How do I move ball shape from corner to corner?

Hi, I need to make a program in processing where a ball moves from each corner of the screen to the other. I keep getting stuck at the 3rd corner.
Another option for my assignment is making a ball grow bigger as it moves from one corner to another. I’m in a very tight time crunch so an answer asap would be very appreciated! :))

1 Like

Show me your code please

I’m sorry, I lost it. I’m not sure how but I think when my little brother got ahold of my computer. Currently trying to redo it but I can’t remember where I left off.

1 Like


  • You have a ball position

  • You add the ball speed to it to make it move

  • Make a counter for the corners and increment it when you reach a corner

Depending upon the counter set the speed



Control ball moving and direction

Greetings @ilhxmun :slightly_smiling_face:

Welcome to the forum!

Just a gentle note:

“Help with a simple program” is a very general description of your question.

I have retitled your topic to match the question in your post.
This will help others who come to the forum in the future with the same/or similar question to search for and find an answer.

If you feel the revised title does not reflect your question, of course, change it to your liking (using descriptive keywords!). :slightly_smiling_face:



here is an example

  • in addition to my post above

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES

int ballX;
int ballY;

int ballXadd=3; 
int ballYadd=3; 

color bkCol; 

void setup() { ///////////////// SET-UP STARTS

  size(300, 300);

  ballX= 0;
  ballY= 0;

  bkCol= 255;
} ///// SET-UP CLOSE

void draw() { ////// DRAW LOOP START

  background (bkCol);

  fill(255, 0, 0); 
  ellipse(ballX, ballY, 6, 6);


  if (dist(ballX, ballY, width, height) < 12) {

1 Like