| 708 | } |
| 709 | |
| 710 | void PlayerObject::collidedWithObject(float dt, GameObject* obj) |
| 711 | { |
| 712 | Vec2 pos = getPosition(); |
| 713 | Rect rect = obj->getOuterBounds(); |
| 714 | |
| 715 | Rect playerRectO = _mini ? getOuterBounds(0.6f, 0.6f) : getOuterBounds(); |
| 716 | Rect playerRectI = getInnerBounds(); |
| 717 | |
| 718 | float flipModV = flipMod(); |
| 719 | |
| 720 | float mod = flipModV * 10.0f; |
| 721 | |
| 722 | if (_currentGamemode == PlayerGamemodeShip) mod = flipModV * 6.0f; |
| 723 | |
| 724 | float topP = (pos.y + (playerRectO.origin.height * -0.5f * -flipMod())) - mod; |
| 725 | float bottomP = (pos.y + (playerRectO.origin.height * -0.5f * flipMod())) + mod; |
| 726 | |
| 727 | float MaxY = rect.getMaxY(); |
| 728 | float MinY = rect.getMinY(); |
| 729 | |
| 730 | // h |
| 731 | float MaxYP = playerRectO.getMaxY(); |
| 732 | float MinYP = playerRectO.getMinY(); |
| 733 | |
| 734 | float t = topP; |
| 735 | float b = bottomP; |
| 736 | |
| 737 | if (isGravityFlipped()) |
| 738 | { |
| 739 | if (_currentGamemode != PlayerGamemodeShip && _currentGamemode != PlayerGamemodeUFO) goto topCollision; |
| 740 | t = bottomP; |
| 741 | b = topP; |
| 742 | } |
| 743 | if (b >= MaxY || t >= MaxY) |
| 744 | { |
| 745 | if (m_dYVel < 0.0f) |
| 746 | { |
| 747 | // checkSnapJumpToObject(obj); |
| 748 | // idk snapping to Y |
| 749 | playerRectI.origin.x = rect.origin.x; |
| 750 | if (playerRectI.intersectsRect(rect)) |
| 751 | { |
| 752 | playerRectI.origin.x = pos.x; |
| 753 | goto death; |
| 754 | } |
| 755 | if (MaxYP >= (MinY + MaxY) / 2.f) |
| 756 | { |
| 757 | setPositionY(MaxY - (_mini ? 6 : 0)); |
| 758 | hitGround(isGravityFlipped() ? _currentGamemode == PlayerGamemodeShip : false); |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | if (!isGravityFlipped()) |
| 764 | { |
| 765 | if (_currentGamemode != PlayerGamemodeShip && _currentGamemode != PlayerGamemodeUFO) goto death; |
| 766 | t = bottomP; |
| 767 | b = topP; |
no test coverage detected