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! :))
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.
Alright
-
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
Hi
Control ball moving and direction
https://funprogramming.org/15-Ball-bouncing-at-the-window-borders.html
Greetings @ilhxmun
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!).
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);
ballX+=ballXadd;
ballY+=ballYadd;
if (dist(ballX, ballY, width, height) < 12) {
bkCol=111;
}
} /////// DRAW LOOP CLOSE
//