This commit is contained in:
parent
ab24781c6d
commit
e04649730a
2 changed files with 42 additions and 42 deletions
|
@ -1268,7 +1268,7 @@ typedef struct
|
||||||
}POSMEM;
|
}POSMEM;
|
||||||
static POSMEM lastpos[NUM_LASTPOS];
|
static POSMEM lastpos[NUM_LASTPOS];
|
||||||
static int lastposnum=0;
|
static int lastposnum=0;
|
||||||
int drawlastpos=false;
|
int drawlastpos=true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __USER_paul__
|
#ifdef __USER_paul__
|
||||||
|
@ -2616,6 +2616,8 @@ int CPlayer::moveVertical(int _moveDistance)
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
extern int checkx;
|
||||||
|
extern int checky;
|
||||||
int CPlayer::moveHorizontal(int _moveDistance)
|
int CPlayer::moveHorizontal(int _moveDistance)
|
||||||
{
|
{
|
||||||
int hitWall;
|
int hitWall;
|
||||||
|
@ -2629,49 +2631,36 @@ int CPlayer::moveHorizontal(int _moveDistance)
|
||||||
|
|
||||||
pos=getPlayerPos();
|
pos=getPlayerPos();
|
||||||
colHeight=getHeightFromGround(pos.vx,pos.vy,5);
|
colHeight=getHeightFromGround(pos.vx,pos.vy,5);
|
||||||
if(colHeight==0)
|
// if(colHeight==0)
|
||||||
{
|
{
|
||||||
// Ok.. we're on the ground. What happens if we move left/right
|
int vx,targetX,checkOfs,moved,x;
|
||||||
colHeight=getHeightFromGround(pos.vx+_moveDistance,pos.vy);
|
|
||||||
if(colHeight<-8)
|
|
||||||
{
|
|
||||||
// Big step up. Stop at the edge of the obstruction
|
|
||||||
int dir,vx,cx,i;
|
|
||||||
if(_moveDistance<0)
|
|
||||||
{
|
|
||||||
dir=-1;
|
|
||||||
vx=-_moveDistance;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dir=+1;
|
|
||||||
vx=_moveDistance;
|
|
||||||
}
|
|
||||||
cx=pos.vx;
|
|
||||||
for(i=0;i<vx;i++)
|
|
||||||
{
|
|
||||||
if(getHeightFromGround(cx,pos.vy)<-8)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cx+=dir;
|
|
||||||
}
|
|
||||||
if(i)
|
|
||||||
pos.vx=cx-dir;
|
|
||||||
|
|
||||||
hitWall=true;
|
vx=_moveDistance<0?-1:+1;
|
||||||
_moveDistance=0;
|
targetX=pos.vx+_moveDistance;
|
||||||
|
checkOfs=vx*checkx;
|
||||||
// Get the height at this new position and then try the step-up code below.
|
moved=0;
|
||||||
// Without this, there are problems when you run up a slope and hit a wall at the same time
|
for(x=pos.vx;x!=targetX;x+=vx)
|
||||||
colHeight=getHeightFromGround(pos.vx,pos.vy);
|
|
||||||
}
|
|
||||||
if(colHeight&&colHeight>=-8&&colHeight<=8)
|
|
||||||
{
|
{
|
||||||
// Small step up/down. Follow the contour of the level
|
// Wall?
|
||||||
pos.vy+=colHeight;
|
colHeight=getHeightFromGround(x+checkOfs,pos.vy);
|
||||||
|
if(colHeight<-checky)
|
||||||
|
{
|
||||||
|
hitWall=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slope?
|
||||||
|
colHeight=getHeightFromGround(x+vx,pos.vy);
|
||||||
|
if(colHeight>=-1&&colHeight<=1)
|
||||||
|
{
|
||||||
|
pos.vy+=colHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
moved+=vx;
|
||||||
}
|
}
|
||||||
|
_moveDistance=moved;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
else if(colHeight>0) // Lets you jump through platforms from below
|
else if(colHeight>0) // Lets you jump through platforms from below
|
||||||
{
|
{
|
||||||
if((CGameScene::getCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&&
|
if((CGameScene::getCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&&
|
||||||
|
@ -2704,6 +2693,7 @@ int CPlayer::moveHorizontal(int _moveDistance)
|
||||||
_moveDistance=0;
|
_moveDistance=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pos.vx+=_moveDistance;
|
pos.vx+=_moveDistance;
|
||||||
setPlayerPos(&pos);
|
setPlayerPos(&pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,14 @@ static PlayerMetrics s_playerMetrics=
|
||||||
} };
|
} };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
int checkx=15;
|
||||||
|
int checky=16;
|
||||||
|
int checkdist=16;
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose:
|
||||||
|
@ -369,7 +377,9 @@ void CPlayerModeBase::thinkVerticalMovement()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
if(m_player->getHeightFromGround(pos.vx,pos.vy,1)!=0)
|
if(m_player->getHeightFromGround(pos.vx,pos.vy,1)!=0&&
|
||||||
|
m_player->getHeightFromGround(pos.vx-checkx,pos.vy,1)!=0&&
|
||||||
|
m_player->getHeightFromGround(pos.vx+checkx,pos.vy,1)!=0)
|
||||||
{
|
{
|
||||||
// Was floating in the air.. fall!
|
// Was floating in the air.. fall!
|
||||||
setState(STATE_FALL);
|
setState(STATE_FALL);
|
||||||
|
@ -574,14 +584,14 @@ int CPlayerModeBase::canMoveLeft()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
return m_player->getHeightFromGround(pos.vx-1,pos.vy,16)>-8?true:false;
|
return m_player->getHeightFromGround(pos.vx-checkx,pos.vy,checkdist)>-checky?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPlayerModeBase::canMoveRight()
|
int CPlayerModeBase::canMoveRight()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
return m_player->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false;
|
return m_player->getHeightFromGround(pos.vx+checkx,pos.vy,checkdist)>-checky?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue