We'll also give MyBall some velocity.
We've given it an x-velocity of 3 pixels per frame, and a y-velocity of 1 pixel per frame, so it moves across the screen more rapidly than it moves downward. Feel free to try different values for the x and y velocities. Whatever you try, it always moves in a straight line.
Note it pretty quickly moves outside the visible portion of the canvas. If you want to see it again, just make a trivial change to the code so the program reloads. Over-typing a space or even just pressing the Shift key will do fine.
|