Project 2.4: Bounce
Balls that bounce off the edge of the screen
REQUIREMENTS
Your program will have at least two balls that bounce off the edges of the screen
They should properly reflect at the correct angle
They can phase through each other - don't worry about collisions
Each ball should...
Start at a different location on the screen
Have a different xSpeed and ySpeed
FAQ / Tips
Progression Advice
Draw a single stationary ball
Make the ball move
Make the ball bounce off the edge
Repeat with a second ball
Wait, but how do I make the ball bounce?
Read Coder's Handbook - Animation carefully. If you want more help, look at Shiffman's bouncing ball example linked on that page.
Is there a way to do this program without repeating so much code?
Yes - but it's beyond your powers right now. We'll come back to this!
I know it's not required, but ... how do I make the balls hit each other?
You'll need to see if one ball is inside of the other one. You have their x positions and y positions, as well as their sizes. If one ball is within another's radius....
EXAMPLE: RUNNING PROGRAM
Lines were added to show predicted motion. They are not displayed in the program.