This commit is contained in:
parent
c33c668be3
commit
3626fc1ecc
8 changed files with 46 additions and 9 deletions
|
@ -156,10 +156,12 @@ void CNpcBubbleTubePlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -169,7 +171,8 @@ void CNpcBubbleTubePlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
|
|
|
@ -360,10 +360,12 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -373,7 +375,8 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
|
|
|
@ -345,10 +345,12 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -358,7 +360,8 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
|
|
|
@ -101,10 +101,12 @@ void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -114,7 +116,8 @@ void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( m_isFalling )
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ void CNpcJellyfishPlatform::collidedWith( CThing *_thisThing )
|
|||
|
||||
s32 height = getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy);
|
||||
|
||||
if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&&
|
||||
if(playerArea.x2>=collisionArea.x1&&playerArea.x1<=collisionArea.x2&&
|
||||
playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2)
|
||||
//if(((playerArea.x1>=collisionArea.x1&&playerArea.x1<=collisionArea.x2)||(playerArea.x2>=collisionArea.x1&&playerArea.x2<=collisionArea.x2)||(playerArea.x1<=collisionArea.x1&&playerArea.x2>=collisionArea.x2))&&
|
||||
//((playerArea.y1>=thatRect.y1&&playerArea.y1<=thatRect.y2)||(playerArea.y2>=thatRect.y1&&playerArea.y2<=thatRect.y2)||(playerArea.y1<=thatRect.y1&&playerArea.y2>=thatRect.y2)))
|
||||
|
|
|
@ -1064,13 +1064,20 @@ u8 CNpcPlatform::checkCollisionDelta( CThing *_thisThing, int threshold, CRECT c
|
|||
s32 oldXPos = otherPos.vx - otherPosDelta.vx;
|
||||
s32 oldYPos = otherPos.vy - otherPosDelta.vy;
|
||||
|
||||
CRECT otherCollisionArea = _thisThing->getCollisionArea();
|
||||
otherCollisionArea.x1 -= otherPosDelta.vx;
|
||||
otherCollisionArea.x2 -= otherPosDelta.vx;
|
||||
otherCollisionArea.y1 -= otherPosDelta.vy;
|
||||
otherCollisionArea.y2 -= otherPosDelta.vy;
|
||||
|
||||
collisionArea.x1 -= posDelta.vx;
|
||||
collisionArea.x2 -= posDelta.vx;
|
||||
collisionArea.y1 -= posDelta.vy;
|
||||
s32 oldCollisionY = collisionArea.y2;
|
||||
collisionArea.y2 -= posDelta.vy;
|
||||
|
||||
if ( oldXPos >= collisionArea.x1 && oldXPos <= collisionArea.x2 )
|
||||
//if ( oldXPos >= collisionArea.x1 && oldXPos <= collisionArea.x2 )
|
||||
if ( otherCollisionArea.x2 >= collisionArea.x1 && otherCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
//if ( oldYPos < collisionArea.y1 + threshold ) //&& otherPos.vy > oldCollisionY )
|
||||
if ( getHeightFromPlatformAtPosition( oldXPos, oldYPos, -posDelta.vx, -posDelta.vy ) > 0 )
|
||||
|
@ -1099,10 +1106,12 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -1112,7 +1121,8 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
|
@ -1296,6 +1306,15 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in
|
|||
top.vx = offsetX + collisionArea.x2;
|
||||
}
|
||||
|
||||
if ( _x > collisionArea.x2 )
|
||||
{
|
||||
_x = collisionArea.x2;
|
||||
}
|
||||
else if ( _x < collisionArea.x1 )
|
||||
{
|
||||
_x = collisionArea.x1;
|
||||
}
|
||||
|
||||
// Rotate backwards to find height at current position
|
||||
|
||||
s16 cosVal = rcos( angle );
|
||||
|
|
|
@ -167,10 +167,12 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
@ -180,7 +182,8 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing )
|
|||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
|
|
|
@ -229,13 +229,16 @@ void CNpcSteerableBarrelPlatform::collidedWith( CThing *_thisThing )
|
|||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
CRECT playerCollisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
playerCollisionArea = player->getCollisionArea();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
//if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, 0, collisionArea ) )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue