| 714 | } |
| 715 | |
| 716 | void 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 |
no test coverage detected