Parabolic throw with set Height and range (libgdx)
- by Tauboga
Currently i'm working on a minigame for android where you have a rotating ball in the center of the display which jumps when touched in the direction of his current angle. I'm simply using a gravity vector and a velocity vector in this way:
positionBall = positionBall.add(velocity);
velocity = velocity.add(gravity);
and
velocity.x = (float) Math.cos(angle) * 12; /* 12 to amplify the velocity */
velocity.y = (float) Math.sin(angle) * 15; /* 15 to amplify the velocity */
That works fine. Here comes the problem:
I want to make the jump look the same on all possible resolutions. The velocity needs to be scaled in a way that when the ball is thrown straight upwards it will touch the upper display border. When thrown directly left or right the range shall be exactly long enough to touch the left/right display border.
Which formula(s) do I need to use and how to implement them correctly? Thanks in advance!