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

Method update

Source/PlayLayer.cpp:716–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716void PlayLayer::update(float dt)
717{
718
719 if (m_freezePlayer)
720 {
721 AudioEngine::pauseAll();
722 return;
723 }
724 else
725 {
726 AudioEngine::resumeAll();
727 }
728
729 float step = std::min(2.0f, dt * 60.0f);
730
731 _player1->m_bIsPlatformer = m_platformerMode;
732 _player1->noclip = noclip;
733 _player2->noclip = noclip;
734
735 auto winSize = Director::getInstance()->getWinSize();
736
737 if (this->_colorChannels.contains(1005)) this->_colorChannels.at(1005)._color = this->_player1->getMainColor();
738 if (this->_colorChannels.contains(1006)) this->_colorChannels.at(1006)._color = this->_player1->getSecondaryColor();
739
740 _colorChannels[1007]._color = getLightBG();
741
742 if (!m_freezePlayer && (!this->_player1->isDead() || !this->_player2->isDead()))
743 {
744 step /= 4.0f;
745 lastY = _player1->getYVel();
746 for (int i = 0; i < 4; i++)
747 {
748 this->_player1->update(step);
749
750 _player1->setOuterBounds(Rect(_player1->getPosition(), Vec2(30, 30)));
751 _player1->setInnerBounds(Rect(_player1->getPosition() + Vec2(11.25f, 11.25f), Vec2(7.5, 7.5)));
752
753 this->checkCollisions(_player1, step);
754
755 if (this->_player1->isDead())
756 break;
757
758 if (!_isDualMode)
759 continue;
760
761 this->_player2->update(step);
762
763 _player2->setOuterBounds(Rect(_player1->getPosition(), Vec2(30, 30)));
764 _player2->setInnerBounds(Rect(_player1->getPosition() + Vec2(11.25f, 11.25f), Vec2(7.5, 7.5)));
765
766 this->checkCollisions(_player2, step);
767
768 if (this->_player2->isDead())
769 break;
770 }
771 step *= 4.0f;
772 }
773

Callers 6

initMethod · 0.45
updateCameraMethod · 0.45
updateVisibilityMethod · 0.45
resetLevelMethod · 0.45
loadLevelMethod · 0.45
updateFunction · 0.45

Calls 13

checkCollisionsMethod · 0.95
showCompleteTextMethod · 0.95
updateVisibilityMethod · 0.95
updateCameraMethod · 0.95
getMainColorMethod · 0.80
getSecondaryColorMethod · 0.80
isDeadMethod · 0.80
getYVelMethod · 0.80
setOuterBoundsMethod · 0.80
setInnerBoundsMethod · 0.80
updateShipRotationMethod · 0.80
Vec2Class · 0.70

Tested by

no test coverage detected