This commit is contained in:
parent
6c807b17f7
commit
6ba1961499
2 changed files with 98 additions and 11 deletions
|
@ -95,6 +95,18 @@
|
||||||
#include "platform\pplayer.h"
|
#include "platform\pplayer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// All platforms are fied to this width at the minute..
|
||||||
|
#define PLATFORMWIDTH 80
|
||||||
|
|
||||||
|
// The collision box is this high.. if SB keeps falling through platforms then it *should* be sufficient
|
||||||
|
// just to up this a bit
|
||||||
|
#define PLATFORMCOLLISIONHEIGHT 50
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class CLayerCollision *CNpcPlatform::m_layerCollision;
|
class CLayerCollision *CNpcPlatform::m_layerCollision;
|
||||||
|
@ -279,9 +291,6 @@ void CNpcPlatform::init()
|
||||||
m_tiltVelocity = 0;
|
m_tiltVelocity = 0;
|
||||||
m_tiltable = false;
|
m_tiltable = false;
|
||||||
|
|
||||||
setCollisionSize(80,50);
|
|
||||||
//setCollisionSize( 200, 20 );
|
|
||||||
|
|
||||||
m_layerCollision = NULL;
|
m_layerCollision = NULL;
|
||||||
|
|
||||||
m_lifetime = 0;
|
m_lifetime = 0;
|
||||||
|
@ -470,12 +479,84 @@ void CNpcPlatform::think(int _frames)
|
||||||
|
|
||||||
processTimer( _frames );
|
processTimer( _frames );
|
||||||
|
|
||||||
//pkg
|
|
||||||
//
|
|
||||||
|
|
||||||
CPlatformThing::think(_frames);
|
CPlatformThing::think(_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcPlatform::setCollisionAngle(int newAngle)
|
||||||
|
{
|
||||||
|
CPlayer *player;
|
||||||
|
|
||||||
|
// Is the player stood on this platform as it rotates?
|
||||||
|
player=GameScene.getPlayer();
|
||||||
|
if(player->isOnPlatform()==this)
|
||||||
|
{
|
||||||
|
DVECTOR playerPos;
|
||||||
|
|
||||||
|
playerPos=player->getPos();
|
||||||
|
if(getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy)==0)
|
||||||
|
{
|
||||||
|
// Ok.. currently stood on the platform - awkward bastard
|
||||||
|
DVECTOR centre;
|
||||||
|
int x,y;
|
||||||
|
DVECTOR shove;
|
||||||
|
|
||||||
|
// Rotate backwards to find x position on platform
|
||||||
|
centre=getCollisionCentre();
|
||||||
|
x=-((centre.vx-playerPos.vx)*mcos(-getCollisionAngle()&4095)>>(12));
|
||||||
|
|
||||||
|
// Rotate forwards to find new position *after* the platform has been rotated
|
||||||
|
y=x*msin(newAngle&4095)>>(12);
|
||||||
|
x=x*mcos(newAngle&4095)>>(12);
|
||||||
|
|
||||||
|
// Shove the player to the new position
|
||||||
|
shove.vx=0;//(x+centre.vx)-playerPos.vx; pkg - can't get this to work :(
|
||||||
|
shove.vy=(y+centre.vy)-playerPos.vy;
|
||||||
|
|
||||||
|
// Finally, to cope with any innacuracies that have been introduced, we run this
|
||||||
|
// new position through the getHeightFromPlatformAtPosition() code and use this to
|
||||||
|
// make sure that the player is still on the platform
|
||||||
|
playerPos.vx+=shove.vx;
|
||||||
|
playerPos.vy+=shove.vy;
|
||||||
|
y=(centre.vy-playerPos.vy)+((centre.vx-playerPos.vx)*msin(-newAngle&4095)>>12);
|
||||||
|
if(y)
|
||||||
|
{
|
||||||
|
shove.vy+=y;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->shove(shove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPlatformThing::setCollisionAngle(newAngle);
|
||||||
|
calculateBoundingBoxSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcPlatform::calculateBoundingBoxSize()
|
||||||
|
{
|
||||||
|
int angle;
|
||||||
|
DVECTOR centre;
|
||||||
|
int halfLength;
|
||||||
|
int x1,y1,x2,y2;
|
||||||
|
|
||||||
|
angle=getCollisionAngle();
|
||||||
|
centre=getCollisionCentre();
|
||||||
|
halfLength=PLATFORMWIDTH/2;
|
||||||
|
|
||||||
|
x1=-halfLength*mcos(angle&4095)>>12;
|
||||||
|
y1=-halfLength*msin(angle&4095)>>12;
|
||||||
|
x2=+halfLength*mcos(angle&4095)>>12;
|
||||||
|
y2=+halfLength*msin(angle&4095)>>12;
|
||||||
|
|
||||||
|
setCollisionSize(abs(x2-x1),abs(y2-y1)+PLATFORMCOLLISIONHEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcPlatform::processTilt( int _frames )
|
void CNpcPlatform::processTilt( int _frames )
|
||||||
|
@ -649,15 +730,13 @@ void CNpcPlatform::render()
|
||||||
// setRGB0(F4,127,127,64);
|
// setRGB0(F4,127,127,64);
|
||||||
// AddPrimToList(F4,2);
|
// AddPrimToList(F4,2);
|
||||||
|
|
||||||
#ifdef __USER_paul__
|
#if defined (__USER_paul__) || defined (__USER_charles__)
|
||||||
DVECTOR centre;
|
DVECTOR centre;
|
||||||
CRECT area;
|
|
||||||
int halfLength;
|
int halfLength;
|
||||||
int x1,y1,x2,y2;
|
int x1,y1,x2,y2;
|
||||||
|
|
||||||
centre=getCollisionCentre();
|
centre=getCollisionCentre();
|
||||||
area=getCollisionArea();
|
halfLength=PLATFORMWIDTH/2;
|
||||||
halfLength=(area.x2-area.x1)/2;
|
|
||||||
|
|
||||||
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
|
x1=-halfLength*mcos(getCollisionAngle()&4095)>>12;
|
||||||
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;
|
y1=-halfLength*msin(getCollisionAngle()&4095)>>12;
|
||||||
|
@ -953,7 +1032,7 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y)
|
||||||
DVECTOR centre;
|
DVECTOR centre;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
// Rotate backwards to find height
|
// Rotate backwards to find height at current position
|
||||||
centre=getCollisionCentre();
|
centre=getCollisionCentre();
|
||||||
y=(centre.vx-_x)*msin(-getCollisionAngle()&4095)>>12;
|
y=(centre.vx-_x)*msin(-getCollisionAngle()&4095)>>12;
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,14 @@ protected:
|
||||||
virtual void collidedWith(CThing *_thisThing);
|
virtual void collidedWith(CThing *_thisThing);
|
||||||
|
|
||||||
static NPC_PLATFORM_UNIT_TYPE mapEditConvertTable[NPC_PLATFORM_TYPE_MAX];
|
static NPC_PLATFORM_UNIT_TYPE mapEditConvertTable[NPC_PLATFORM_TYPE_MAX];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setCollisionAngle(int newAngle); // Actually.. this probly doesn't need to be in the base calss anymore.. :/
|
||||||
|
void calculateBoundingBoxSize();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue