This is probably done best by emulating 3D. The following is 3D maths cut down to the bare minimum needed for your case. In the following I presume that you define an [initial scale]
and a [final scale]
for the ball according to how large/close you want it to appear, along with start and end coordinates, and the [time]
it should take. You should also define a [gravity]
constant.
Scale
The [ball scale]
should be proportionate to 1/[distance to screen]
, where [distance to screen]
should decrease linearly with time, it must not reach 0, but should rather decrease to the point where the ball has the desired size.
It doesn't matter what unit the distance is measured in, so the easiest this to do is simply to declare the [initial distance]
to be equal to 1/[initial scale]
and [final distance] = 1/[final scale]
Position
The ball should also move across the screen in the same non-linear fashion that it scales, so when you have calculated [ball scale]
you can use that to get the position as well, it would simply be
[position] = [start position] + ([end position] - [start position]) *
([ball scale]-[initial scale]) / ([final scale]-[initial scale])
Gravity
This makes the ball seem to move through the air in a straight line, real balls tend not to do that because of gravity, save for very speedy shots it would look weird if the ball's path doesn't bend downwards. First we need parabola that goes through 0 at the initial and final distance to screen:
[height] = ([distance to screen]-[initial distance]) *
([final distance]-[distance to screen])
Then this parabola should be scaled to the desired level of gravity and to give greater height to slow balls:
[height] = [height] * [gravity] * [time]^2
Finally the visual representation of this height should be scaled like the ball:
[visual height] = [height] * [ball scale]
The [visual height] should then be added to the vertical part of the screen position. Depending on time and gravity scale this may make the ball go off screen for part of the shot.
Don't hesitate to ask if something isn't clear.