This commit is contained in:
Charles 2001-08-17 14:25:04 +00:00
parent 3de0332396
commit 759dafc875
3 changed files with 55 additions and 19 deletions

View File

@ -653,6 +653,7 @@ m_animFrame=0;
resetPlayerCollisionSizeToBase(); resetPlayerCollisionSizeToBase();
m_lockoutPlatform = NULL;
m_divingHelmet=false; m_divingHelmet=false;
setIsInWater(true); setIsInWater(true);
@ -765,13 +766,14 @@ if(newmode!=-1)
{ {
int goingToHitWall=false; int goingToHitWall=false;
int i; int i;
for(i=0;i<2;i++) for(i=-1;i<2;i++)
{ {
int x=Pos.vx+((i==0?-checkx:+checkx)); int x=Pos.vx+(checkx*i);
int y=Pos.vy-HEIGHT_FOR_HEAD_COLLISION; int y=Pos.vy-HEIGHT_FOR_HEAD_COLLISION;
if(getHeightFromGroundNoPlatform(x,y,16)>=0&&getHeightFromGroundNoPlatform(x,y+platformOffset,16)<=0&&((CGameScene::getCollision()->getCollisionBlock(x,y+platformOffset)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL)) if(getHeightFromGroundNoPlatform(x,y,16)>=0&&getHeightFromGroundNoPlatform(x,y+platformOffset,16)<=0&&((CGameScene::getCollision()->getCollisionBlock(x,y+platformOffset)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL))
{ {
goingToHitWall=true; goingToHitWall=true;
setLockoutPlatform( m_platform );
break; break;
} }
} }
@ -2680,13 +2682,41 @@ void CPlayer::buttFall()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayer::setPlatform(CThing *_newPlatform) void CPlayer::setPlatform(CThing *_newPlatform)
{ {
m_platform=_newPlatform; if ( _newPlatform != m_lockoutPlatform )
{
m_platform=_newPlatform;
m_lockoutPlatform = NULL;
}
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayer::clearPlatform() void CPlayer::clearPlatform()
{ {
m_platform=NULL; m_platform=NULL;
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayer::setLockoutPlatform(CThing *_newPlatform)
{
// this platform is not to be used until the player has hit either
// (a) another platform
// (b) the ground
// should stop player-platform interaction when he is knocked off by collision
m_lockoutPlatform = _newPlatform;
}
@ -2766,23 +2796,23 @@ int CPlayer::moveVertical(int _moveDistance)
} }
else if(_moveDistance<0) else if(_moveDistance<0)
{ {
int colHeightBefore[2],colHeightAfter[2],blockAfter[2],moveRequired[2]; int colHeightBefore[3],colHeightAfter[3],blockAfter[3],moveRequired[3];
int i; int i;
int move; int move;
// -------------- Jumping - See if the feet have hit anything -------------- // -------------- Jumping - See if the feet have hit anything --------------
// Get heights of the two edges // Get heights of the two edges
for(i=0;i<+2;i++) for(i=-1;i<+2;i++)
{ {
int x=pos.vx+((i==0?-checkx:+checkx)); int x=pos.vx+(checkx*i);
colHeightBefore[i]=getHeightFromGround(x,pos.vy,16); colHeightBefore[i+1]=getHeightFromGround(x,pos.vy,16);
colHeightAfter[i]=getHeightFromGround(x,pos.vy+_moveDistance,16); colHeightAfter[i+1]=getHeightFromGround(x,pos.vy+_moveDistance,16);
blockAfter[i]=CGameScene::getCollision()->getCollisionBlock(x,pos.vy+_moveDistance); blockAfter[i+1]=CGameScene::getCollision()->getCollisionBlock(x,pos.vy+_moveDistance);
} }
// See if either side is about to go through the ground // See if either side is about to go through the ground
for(i=0;i<2;i++) for(i=0;i<3;i++)
{ {
if(colHeightBefore[i]>=0&&colHeightAfter[i]<=0&&((blockAfter[i]&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL)) if(colHeightBefore[i]>=0&&colHeightAfter[i]<=0&&((blockAfter[i]&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL))
{ {
@ -2798,7 +2828,7 @@ int CPlayer::moveVertical(int _moveDistance)
// Find the smallest move required to hit ground // Find the smallest move required to hit ground
move=0; move=0;
for(i=0;i<2;i++) for(i=0;i<3;i++)
{ {
if(moveRequired[i]<move) if(moveRequired[i]<move)
{ {
@ -2813,20 +2843,21 @@ int CPlayer::moveVertical(int _moveDistance)
// Get heights of the two edges // Get heights of the two edges
int y=pos.vy-HEIGHT_FOR_HEAD_COLLISION; int y=pos.vy-HEIGHT_FOR_HEAD_COLLISION;
for(i=0;i<+2;i++) for(i=-1;i<+2;i++)
{ {
int x=pos.vx+((i==0?-checkx:+checkx)); int x=pos.vx+(checkx*i);
colHeightBefore[i]=getHeightFromGround(x,y,16); colHeightBefore[i+1]=getHeightFromGround(x,y,16);
colHeightAfter[i]=getHeightFromGround(x,y+_moveDistance,16); colHeightAfter[i+1]=getHeightFromGround(x,y+_moveDistance,16);
blockAfter[i]=CGameScene::getCollision()->getCollisionBlock(x,y+_moveDistance); blockAfter[i+1]=CGameScene::getCollision()->getCollisionBlock(x,y+_moveDistance);
} }
// See if either side is about to go through the ground // See if either side is about to go through the ground
for(i=0;i<2;i++) for(i=0;i<3;i++)
{ {
if(colHeightBefore[i]>=0&&colHeightAfter[i]<=0&&((blockAfter[i]&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL)) if(colHeightBefore[i]>=0&&colHeightAfter[i]<=0&&((blockAfter[i]&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL))
{ {
moveRequired[i]=16+colHeightAfter[i]; //moveRequired[i]=16+colHeightAfter[i];
moveRequired[i]=colHeightAfter[i];
// hitGround=true; // hitGround=true;
// do not call hitground code, because this will set it to STATE_IDLE for a frame // do not call hitground code, because this will set it to STATE_IDLE for a frame
@ -2849,7 +2880,7 @@ int CPlayer::moveVertical(int _moveDistance)
// Find the smallest move required to hit ground // Find the smallest move required to hit ground
move=0; move=0;
for(i=0;i<2;i++) for(i=0;i<3;i++)
{ {
if(moveRequired[i]<move) if(moveRequired[i]<move)
{ {

View File

@ -470,11 +470,13 @@ private:
// Platforms // Platforms
public: public:
void setPlatform(CThing *_newPlatform); void setPlatform(CThing *_newPlatform);
void setLockoutPlatform(CThing *_newPlatform);
void clearPlatform(); void clearPlatform();
CThing *isOnPlatform() {return m_platform;} CThing *isOnPlatform() {return m_platform;}
private: private:
CThing *m_platform; CThing *m_platform;
CThing *m_lockoutPlatform;
// Player collision size // Player collision size

View File

@ -433,6 +433,9 @@ void CPlayerModeBase::playerHasHitGround()
moveVel=*m_player->getMoveVelocity(); moveVel=*m_player->getMoveVelocity();
moveVel.vy=0; moveVel.vy=0;
m_fallFrames=0; m_fallFrames=0;
m_player->setLockoutPlatform( NULL );
if(m_currentState==STATE_BUTTFALL) if(m_currentState==STATE_BUTTFALL)
{ {
// Landed from a butt bounce // Landed from a butt bounce