MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / PhysicsComp_CalcJumpVelocity

Function PhysicsComp_CalcJumpVelocity

src/EntityComponents.c:1014–1024  ·  view source on GitHub ↗

Calculates the jump velocity required such that when user presses the jump binding they will be able to jump up to the given height. */

Source from the content-addressed store, hash-verified

1012/* Calculates the jump velocity required such that when user presses
1013the jump binding they will be able to jump up to the given height. */
1014float PhysicsComp_CalcJumpVelocity(float jumpHeight) {
1015 float jumpVel = 0.0f;
1016 if (jumpHeight == 0.0f) return jumpVel;
1017
1018 if (jumpHeight >= 256.0f) jumpVel = 10.0f;
1019 if (jumpHeight >= 512.0f) jumpVel = 16.5f;
1020 if (jumpHeight >= 768.0f) jumpVel = 22.5f;
1021
1022 while (PhysicsComp_CalcMaxHeight(jumpVel) <= jumpHeight) { jumpVel += 0.001f; }
1023 return jumpVel;
1024}
1025
1026void PhysicsComp_DoEntityPush(struct Entity* entity) {
1027 struct Entity* other;

Callers 3

HS_SetJumpFunction · 0.85
CPE_HackControlFunction · 0.85
CalcVelocityFunction · 0.85

Calls 1

Tested by

no test coverage detected