This commit is contained in:
parent
c85c9ee1d7
commit
cf1405ecd5
2 changed files with 189 additions and 1 deletions
|
@ -19,6 +19,14 @@
|
|||
#include "utils\utils.h"
|
||||
#endif
|
||||
|
||||
#ifndef __VID_HEADER_
|
||||
#include "system\vid.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -38,7 +46,7 @@ void CNpcDualPlatform::setOtherPlatform( CNpcDualPlatform *other )
|
|||
|
||||
void CNpcDualPlatform::setWaypoints( sThingPlatform *ThisPlatform )
|
||||
{
|
||||
ASSERT( ThisPlatform->PointCount == 3 );
|
||||
ASSERT( ThisPlatform->PointCount >= 3 );
|
||||
|
||||
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
|
||||
|
||||
|
@ -73,6 +81,9 @@ void CNpcDualPlatform::setWaypoints( sThingPlatform *ThisPlatform )
|
|||
// get slave platform init x pos
|
||||
|
||||
newXPos = (u16) *PntList;
|
||||
PntList++;
|
||||
newYPos = (u16) *PntList;
|
||||
PntList++;
|
||||
|
||||
DVECTOR slavePos;
|
||||
slavePos.vx = newXPos << 4;
|
||||
|
@ -80,6 +91,34 @@ void CNpcDualPlatform::setWaypoints( sThingPlatform *ThisPlatform )
|
|||
|
||||
m_otherPlatform->init( slavePos );
|
||||
m_otherPlatform->postInit();
|
||||
|
||||
if ( ThisPlatform->PointCount > 3 )
|
||||
{
|
||||
DVECTOR base;
|
||||
|
||||
base.vx = (u16) *PntList;
|
||||
base.vx <<= 4;
|
||||
PntList++;
|
||||
base.vy = (u16) *PntList;
|
||||
base.vy <<= 4;
|
||||
PntList++;
|
||||
|
||||
m_otherPlatform->setLineBase( base );
|
||||
|
||||
base.vx = (u16) *PntList;
|
||||
base.vx <<= 4;
|
||||
PntList++;
|
||||
base.vy = (u16) *PntList;
|
||||
base.vy <<= 4;
|
||||
PntList++;
|
||||
|
||||
setLineBase( base );
|
||||
}
|
||||
else
|
||||
{
|
||||
setLineBase( Pos );
|
||||
m_otherPlatform->setLineBase( slavePos );
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -157,3 +196,148 @@ void CNpcDualPlatform::setMovement( DVECTOR move )
|
|||
Pos.vx += move.vx;
|
||||
Pos.vy += move.vy;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcDualPlatform::render()
|
||||
{
|
||||
int x1,y1,x2,y2;
|
||||
|
||||
setOnScreenFlag(false);
|
||||
if ( m_isActive )
|
||||
{
|
||||
CPlatformThing::render();
|
||||
|
||||
// Render
|
||||
DVECTOR renderPos;
|
||||
DVECTOR offset = CLevel::getCameraPos();
|
||||
|
||||
renderPos.vx = Pos.vx - offset.vx;
|
||||
renderPos.vy = Pos.vy - offset.vy;
|
||||
|
||||
CRECT collisionRect = getCollisionArea();
|
||||
collisionRect.x1 -= Pos.vx;
|
||||
collisionRect.x2 -= Pos.vx;
|
||||
collisionRect.y1 -= Pos.vy;
|
||||
collisionRect.y2 -= Pos.vy;
|
||||
|
||||
if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() )
|
||||
{
|
||||
if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() )
|
||||
{
|
||||
setOnScreenFlag(true);
|
||||
m_modelGfx->Render(renderPos);
|
||||
// POLY_F4 *F4=GetPrimF4();
|
||||
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
|
||||
// setRGB0(F4,127,127,64);
|
||||
// AddPrimToList(F4,2);
|
||||
|
||||
#if defined (__USER_paul__) || defined (__USER_charles__)
|
||||
DVECTOR size;
|
||||
DVECTOR centre;
|
||||
int halfLength;
|
||||
|
||||
centre=getCollisionCentre();
|
||||
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;
|
||||
|
||||
centre.vx-=offset.vx;
|
||||
centre.vy-=offset.vy;
|
||||
x1+=centre.vx;
|
||||
y1+=centre.vy;
|
||||
x2+=centre.vx;
|
||||
y2+=centre.vy;
|
||||
|
||||
DrawLine(x1,y1,x2,y2,0,255,0,0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
x1 = Pos.vx - offset.vx;
|
||||
x2 = m_lineBase.vx - offset.vx;
|
||||
|
||||
if ( x1 > x2 )
|
||||
{
|
||||
int tempX = x1;
|
||||
x1 = x2;
|
||||
x2 = tempX;
|
||||
}
|
||||
|
||||
y1 = Pos.vy - offset.vy;
|
||||
y2 = m_lineBase.vy - offset.vy;
|
||||
|
||||
if ( y1 > y2 )
|
||||
{
|
||||
int tempY = y1;
|
||||
y1 = y2;
|
||||
y2 = tempY;
|
||||
}
|
||||
|
||||
if ( y1 < 0 )
|
||||
{
|
||||
y1 = 0;
|
||||
}
|
||||
|
||||
if ( y2 > VidGetScrH() )
|
||||
{
|
||||
y2 = VidGetScrH();
|
||||
}
|
||||
|
||||
if ( x2 >= 0 && x1 <= VidGetScrW() )
|
||||
{
|
||||
if ( y2 >= 0 && y1 <= VidGetScrH() )
|
||||
{
|
||||
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_isMaster )
|
||||
{
|
||||
DVECTOR otherLineBase = m_otherPlatform->getLineBase();
|
||||
|
||||
x1 = otherLineBase.vx - offset.vx;
|
||||
x2 = m_lineBase.vx - offset.vx;
|
||||
|
||||
if ( x1 > x2 )
|
||||
{
|
||||
int tempX = x1;
|
||||
x1 = x2;
|
||||
x2 = tempX;
|
||||
}
|
||||
|
||||
y1 = otherLineBase.vy - offset.vy;
|
||||
y2 = m_lineBase.vy - offset.vy;
|
||||
|
||||
if ( y1 > y2 )
|
||||
{
|
||||
int tempY = y1;
|
||||
y1 = y2;
|
||||
y2 = tempY;
|
||||
}
|
||||
|
||||
if ( x1 < 0 )
|
||||
{
|
||||
x1 = 0;
|
||||
}
|
||||
|
||||
if ( x2 > VidGetScrW() )
|
||||
{
|
||||
x2 = VidGetScrW();
|
||||
}
|
||||
|
||||
if ( x2 >= 0 && x1 <= VidGetScrW() )
|
||||
{
|
||||
if ( y2 >= 0 && y1 <= VidGetScrH() )
|
||||
{
|
||||
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ public:
|
|||
void setOtherPlatform( CNpcDualPlatform *other );
|
||||
void setMovement( DVECTOR move );
|
||||
virtual u8 canDrop();
|
||||
void setLineBase( DVECTOR base ) {m_lineBase = base;}
|
||||
DVECTOR getLineBase() {return( m_lineBase );}
|
||||
virtual void render();
|
||||
protected:
|
||||
virtual void setWaypoints( sThingPlatform *ThisPlatform );
|
||||
virtual void processMovement( int _frames );
|
||||
|
@ -33,6 +36,7 @@ protected:
|
|||
CNpcDualPlatform *m_otherPlatform;
|
||||
s32 m_maxExtension;
|
||||
s32 m_extension;
|
||||
DVECTOR m_lineBase;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue