Crossposted from the ANTONBLAST kickstarter page Heyo, it’s me, lovable lead programmer on ANTONBLAST Massimo Gauthier, here to talk about how I implemented the layer jumping mechanic! By following this simple guide, you too can become authentically inspired by 90s and 2000s era 2D platformers and their weird pseudo-3D gimmicks!
In the loop, we want to get _currentJumpTime to equal layerJumpTime (which is known), so replace _currentJumpTime with layerJumpTime, noting that _jumpDistance and _fallDistance are already known:
Creating ANTONBLAST's Layer Jump System
I really enjoyed this post! I think I have a direct solution to solve for gravity. Sorry, I didn't bother to make it pretty.
So basically, we have this, which was obtained by plugging in the expression for _timeToApex into the expression for _currentJumpTime:
_currentJumpTime = sqrt(2*_jumpDistance/layerJumpGrav) + sqrt(2*_fallDistance/layerJumpGrav);
In the loop, we want to get _currentJumpTime to equal layerJumpTime (which is known), so replace _currentJumpTime with layerJumpTime, noting that _jumpDistance and _fallDistance are already known:
layerJumpTime = sqrt(2*_jumpDistance/layerJumpGrav) + sqrt(2*_fallDistance/layerJumpGrav);
Factor out sqrt(1/layerJumpGrav):
layerJumpTime = sqrt(1/layerJumpGrav)*(sqrt(2*_jumpDistance) + sqrt(2*_fallDistance));
Muliply both sides by sqrt(layerJumpGrav):
layerJumpTime*sqrt(layerJumpGrav) = sqrt(2*_jumpDistance) + sqrt(2*_fallDistance);
Divide both sides by layerJumpTime:
sqrt(layerJumpGrav) = (sqrt(2*_jumpDistance) + sqrt(2*_fallDistance))/layerJumpTime;
square both sides:
layerJumpGrav = ((sqrt(2*_jumpDistance) + sqrt(2*_fallDistance))/layerJumpTime)^2;
Now, once you have layerJumpGrav, you can find layerJumpVerticalSpeed and _timeToApex