Project 2.6: Orbit
Make a circle that follows the mouse on the screen
The ball should start at a random position anywhere on the screen
Your ball should try to follow the mouse by changing its speed when it is going the wrong way
It should accelerate at a rate of 1 pixel per frame
The ball should have a maximum speed of 25 pixels per frame.
The ball should change color each frame.
This can be totally random or within a limited but still random color set.
FAQ / Tips
I'm a little confused on negative maximum speeds
So if we're going to the right, that means xSpeed is positive. So maxSpeed must be positive. We then ask:
if(ySpeed < maxSpeed)
But if we're going to the left, xSpeed is negative. It's always going to be under maxSpeed. So we need to instead ask:
if(ySpeed > -maxSpeed)
Why does my orbit look square-ish if I leave it stationary?
This is okay! We're using some simple math, treating x and y speed independently. It isn't actually a proper circle. You'll need to use more advanced math for that.
You're welcome to do so, or ask a math / physics teacher for help, but it's beyond the scope of our requirements.
EXAMPLE: RUNNING PROGRAMS