Parabolic throw with set Height and range (libgdx)
Posted
by
Tauboga
on Game Development
See other posts from Game Development
or by Tauboga
Published on 2014-08-18T20:05:15Z
Indexed on
2014/08/18
22:33 UTC
Read the original article
Hit count: 427
mathematics
|libgdx
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!
© Game Development or respective owner