This commit is contained in:
Charles 2001-04-25 16:18:52 +00:00
parent 1c5929ca5e
commit 7f75195e1a
4 changed files with 54 additions and 12 deletions

View File

@ -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;
}

View File

@ -31,6 +31,7 @@ class CNpcStaticClamEnemy : public CNpcClamEnemy
{
public:
virtual void postInit();
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
protected:
virtual void collidedWith(CThing *_thisThing);
virtual void processShot();

View File

@ -854,19 +854,9 @@ int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
{
_thisThing->setHasPlatformCollided( true );
_thisThing->setCentreCollision( true );
_thisThing->setNewCollidedPos( thatPos );
}
}
else
{
_thisThing->setCentreCollision( false );
}
}
else
{
_thisThing->setCentreCollision( false );
}
}
}

View File

@ -143,7 +143,6 @@ public:
int getCollisionRadius() {return m_collisionRadius;}
CRECT getCollisionArea() {return m_collisionArea;}
s16 getCollisionAngle() {return m_collisionAngle;}
bool getCentreCollision() {return m_centreCollision;}
DVECTOR getNewCollidedPos() {return m_newCollidedPos;}
DVECTOR getCollisionSize() {return m_collisionSize;}
@ -156,7 +155,6 @@ public:
virtual bool getHasPlatformCollided() {return false;}
virtual s32 getNewYPos( CThing *_thisThing );
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;}
void setCentreCollision(bool newCentreCollision) {m_centreCollision = newCentreCollision;}
protected: