bool CDeathPirate::CheckCollision(CBase* pBase) { CBase::CheckCollision( pBase ); if(pBase->GetType() == OBJ_BLOCK) { CBlock* BLOCK = (CBlock*)pBase; RECT rIntersect; //Descriptive replacement variables RECT rMyRect = { (LONG)GetPosX(), (LONG)GetPosY(), 0, 0 }; rMyRect.right = rMyRect.left + GetWidth(); rMyRect.bottom = rMyRect.top + GetHeight(); RECT rHisRect = { (LONG)BLOCK->GetPosX(), (LONG)BLOCK->GetPosY(), 0, 0 }; rHisRect.right = rHisRect.left + BLOCK->GetWidth(); rHisRect.bottom = rHisRect.top + BLOCK->GetHeight(); if( IntersectRect( &rIntersect, &rMyRect, &rHisRect ) ) { if( (rIntersect.right-rIntersect.left) > (rIntersect.bottom-rIntersect.top) ) { if(BLOCK->GetBlock() == BLOCK_SOLID || BLOCK->GetBlock() == BLOCK_MOVING || BLOCK->GetBlock() == BLOCK_PARTIAL || BLOCK->GetBlock() == BLOCK_UNSTABLE) { if(rMyRect.bottom > rHisRect.top && rMyRect.top < rHisRect.top) { SetPosY( (float)rHisRect.top - GetHeight() ); SetGround(true); SetBaseVelY(0); SetCollision(true); } else if(rMyRect.top < rHisRect.bottom && rMyRect.bottom > rHisRect.top) SetPosY((float)rHisRect.bottom); } else if(BLOCK->GetBlock() == BLOCK_TRAP) { SetGround(true); SetCollision(true); SetBaseVelY(0); } } else if((rIntersect.right-rIntersect.left) < (rIntersect.bottom-rIntersect.top)) { if(BLOCK->GetBlock() == BLOCK_SOLID || BLOCK->GetBlock() == BLOCK_MOVING || BLOCK->GetBlock() == BLOCK_PARTIAL) { } else if(BLOCK->GetBlock() == BLOCK_TRAP) { SetGround(true); SetCollision(true); SetBaseVelY(0); } } return true; } } if(GetGround() && GetCollision() == false) { SetGround(false); } return false; }