This commit is contained in:
Charles 2001-05-02 15:32:47 +00:00
parent ae6b5ef072
commit 6c221940f6
6 changed files with 77 additions and 9 deletions

View file

@ -128,11 +128,13 @@ void CNpcBouncePlatform::render()
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR centre;
DVECTOR size;
int halfLength;
int x1,y1,x2,y2;
centre=getCollisionCentre();
halfLength=PLATFORMWIDTH/2;
size=getCollisionSize();
halfLength=size.vx>>1;
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;

View file

@ -37,6 +37,7 @@
void CNpcBranchPlatform::postInit()
{
m_angularVelocity = 0;
m_platformWidth <<= 1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -81,6 +82,48 @@ void CNpcBranchPlatform::setWaypoints( sThingPlatform *ThisPlatform )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::collidedWith( CThing *_thisThing )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
if ( m_detectCollision && m_isActive )
{
CPlayer *player;
DVECTOR playerPos;
CRECT collisionArea;
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
playerPos=player->getPos();
collisionArea=getCollisionArea();
if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&&
playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2)
{
if ( ( m_reversed && playerPos.vx <= Pos.vx ) || ( !m_reversed && playerPos.vx >= Pos.vx ) )
{
player->setPlatform( this );
if(getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy)==0)
{
m_contact = true;
}
}
}
}
break;
}
default:
ASSERT(0);
break;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::processMovement( int _frames )
{
s16 newAngle = getCollisionAngle();
@ -209,17 +252,30 @@ void CNpcBranchPlatform::render()
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
DVECTOR centre;
int halfLength;
int x1,y1,x2,y2;
centre=getCollisionCentre();
halfLength=PLATFORMWIDTH/2;
size=getCollisionSize();
halfLength=size.vx>>1;
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;
x2=+halfLength*mcos(getCollisionAngle()&4095)>>12;
y2=+halfLength*msin(getCollisionAngle()&4095)>>12;
x1=0;
x2=0;
y1=0;
y2=0;
if ( m_reversed )
{
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;
}
else
{
x2=+halfLength*mcos(getCollisionAngle()&4095)>>12;
y2=+halfLength*msin(getCollisionAngle()&4095)>>12;
}
centre.vx-=offset.vx;
centre.vy-=offset.vy;

View file

@ -27,6 +27,8 @@ protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames );
virtual void collidedWith(CThing *_thisThing);
s32 m_angularVelocity;
u8 m_reversed;
};

View file

@ -310,6 +310,8 @@ void CNpcPlatform::init()
m_isShuttingDown = false;
m_platformWidth = PLATFORMWIDTH;
m_npcPath.initPath();
}
@ -558,7 +560,7 @@ void CNpcPlatform::calculateBoundingBoxSize()
angle=getCollisionAngle();
centre=getCollisionCentre();
halfLength=PLATFORMWIDTH/2;
halfLength=m_platformWidth/2;
x1=-halfLength*mcos(angle&4095)>>12;
y1=-halfLength*msin(angle&4095)>>12;
@ -746,12 +748,14 @@ void CNpcPlatform::render()
// AddPrimToList(F4,2);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
DVECTOR centre;
int halfLength;
int x1,y1,x2,y2;
centre=getCollisionCentre();
halfLength=PLATFORMWIDTH/2;
size=getCollisionSize();
halfLength=size.vx>>1;
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;

View file

@ -199,6 +199,8 @@ protected:
CModelGfx *m_modelGfx;
u8 m_isShuttingDown;
u8 m_platformWidth;
virtual void collidedWith(CThing *_thisThing);
static NPC_PLATFORM_UNIT_TYPE mapEditConvertTable[NPC_PLATFORM_TYPE_MAX];

View file

@ -141,12 +141,14 @@ void CNpcSeesawPlatform::render()
m_modelGfx->Render(renderPos,&rotation,&scale);
#if defined (__USER_paul__) || defined (__USER_charles__)
DVECTOR size;
DVECTOR centre;
int halfLength;
int x1,y1,x2,y2;
centre=getCollisionCentre();
halfLength=PLATFORMWIDTH/2;
size=getCollisionSize();
halfLength=size.vx>>1;
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;