MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / updateJump

Method updateJump

Source/PlayerObject.cpp:560–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560void PlayerObject::updateJump(float dt)
561{
562 float localGravity = m_dGravity;
563
564 const int flipGravityMult = flipMod();
565
566 float playerSize = _mini ? 0.8f : 1.0f;
567
568 if (_currentGamemode == PlayerGamemodeShip || _currentGamemode == PlayerGamemodeUFO ||
569 _currentGamemode == PlayerGamemodeWave)
570 {
571 if (_mini) playerSize = 0.85f;
572
573 float upperVelocityLimit = 8.0 / playerSize;
574 float lowerVelocityLimit = -6.4 / playerSize;
575
576 if (this->_currentGamemode == PlayerGamemodeShip)
577 {
578 float shipAccel = 0.8f;
579
580 if (this->m_bIsHolding) shipAccel = -1.0f;
581
582 if (!this->m_bIsHolding && !this->playerIsFalling())
583 {
584 shipAccel = 1.2f;
585 }
586
587 float extraBoost = 0.4f;
588 if (this->m_bIsHolding && this->playerIsFalling()) extraBoost = 0.5;
589
590 this->m_dYVel -= localGravity * dt * flipGravityMult * shipAccel * extraBoost / playerSize;
591 }
592 else if (_currentGamemode == PlayerGamemodeUFO)
593 {
594 if (m_bIsHolding && _hasJustHeld)
595 {
596 _hasJustHeld = false;
597
598 const float sizeMult = _mini ? 8.f : 7.f;
599 double newVel = flipMod() * sizeMult * playerSize;
600
601 if (!isGravityFlipped() && m_dYVel < newVel || newVel < m_dYVel)
602 {
603 m_dYVel = newVel;
604 }
605 }
606 float gravityMult = 0.8f;
607
608 if (!playerIsFalling()) gravityMult = 1.2f;
609
610 m_dYVel -= localGravity * dt * flipMod() * gravityMult * 0.5 / playerSize;
611 }
612
613 if (!this->isGravityFlipped())
614 {
615 if (this->m_dYVel <= lowerVelocityLimit) this->m_dYVel = lowerVelocityLimit;
616 }
617 else

Callers 1

updateMethod · 0.95

Calls 3

playerIsFallingMethod · 0.95
isGravityFlippedMethod · 0.95
flipGravityMethod · 0.95

Tested by

no test coverage detected