This commit is contained in:
parent
1c5929ca5e
commit
7f75195e1a
4 changed files with 54 additions and 12 deletions
|
@ -189,3 +189,56 @@ void CNpcStaticClamEnemy::collidedWith( CThing *_thisThing )
|
|||
CNpcClamEnemy::collidedWith( _thisThing );
|
||||
}
|
||||
}
|
||||
|
||||
int CNpcStaticClamEnemy::checkCollisionAgainst( CThing *_thisThing, int _frames )
|
||||
{
|
||||
DVECTOR pos,thisThingPos;
|
||||
int radius;
|
||||
int collided;
|
||||
|
||||
pos = getCollisionCentre();
|
||||
thisThingPos=_thisThing->getCollisionCentre();
|
||||
|
||||
radius=getCollisionRadius()+_thisThing->getCollisionRadius();
|
||||
collided=false;
|
||||
if(abs(pos.vx-thisThingPos.vx)<radius&&
|
||||
abs(pos.vy-thisThingPos.vy)<radius)
|
||||
{
|
||||
CRECT thisRect,thatRect;
|
||||
|
||||
thisRect=getCollisionArea();
|
||||
|
||||
thatRect=_thisThing->getCollisionArea();
|
||||
|
||||
if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&&
|
||||
((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2)))
|
||||
{
|
||||
switch(_thisThing->getThingType())
|
||||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
if ( m_isStunned && m_isActive )
|
||||
{
|
||||
CPlayer *player = (CPlayer *) _thisThing;
|
||||
|
||||
s32 playerDeltaY = player->getPosDelta().vy;
|
||||
|
||||
if ( thisThingPos.vy - playerDeltaY <= getNewYPos( _thisThing ) )
|
||||
{
|
||||
player->setPlatform( this );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
collided=true;
|
||||
}
|
||||
}
|
||||
|
||||
return collided;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue