We are glad to help you if you have problems getting your Code to run, or don’t know how to do something, but please try it yourself first, but obviously we still can direct you to the right answer, so that you can achive it yourself and therefore learn and improve your problem-solving and Processing skills.
To make what you what, you just need to create a circle for the ball, which can be done with ellipse(x, y, width, height). Then you can move the ball either using translate(x, y) to move it. You can also get the x and y coordinates of the mouse by using the mouseX and mouseY variables respectively. Then you just need to check if the position of the ball is outside the bounds of your sketch in this case, or a rectangle in general. This can be done by checking if the x or y position of your ball is bigger than the size of your sketch, or smaller than 0 in your case. And if it is, then set the position of the ball to where you want it to be. In your case width/2, height/2.
Hope this helps
3 Likes