This commit is contained in:
parent
13b012d19d
commit
cb4e61508c
2 changed files with 61 additions and 14 deletions
|
@ -62,6 +62,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define SLIPSPEED 10 // Speed that player slips on icy surfaces
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Structure defintions
|
Structure defintions
|
||||||
-------------------- */
|
-------------------- */
|
||||||
|
@ -287,7 +289,7 @@ if(newmode!=-1)
|
||||||
m_currentStateClass->think(this);
|
m_currentStateClass->think(this);
|
||||||
|
|
||||||
// Horizontal movement
|
// Horizontal movement
|
||||||
if(m_layerCollision->Get((Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT))>>4,(Pos.vy-1)>>4))
|
if(m_moveVel.vx&&m_layerCollision->Get((Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT))>>4,(Pos.vy-2)>>4))
|
||||||
{
|
{
|
||||||
// Will hit a wall this frame - Do collision
|
// Will hit a wall this frame - Do collision
|
||||||
// Move flush with the edge of the obstruction
|
// Move flush with the edge of the obstruction
|
||||||
|
@ -328,25 +330,25 @@ if(newmode!=-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertical movement
|
// Vertical movement
|
||||||
|
int colHeight;
|
||||||
Pos.vy+=m_moveVel.vy>>VELOCITY_SHIFT;
|
Pos.vy+=m_moveVel.vy>>VELOCITY_SHIFT;
|
||||||
if(isOnSolidGround())
|
if((colHeight=isOnSolidGround()))
|
||||||
{
|
{
|
||||||
//stick to ground (PKG)
|
//stick to ground (PKG)
|
||||||
//Pos.vy=23*16+1;//16*15;
|
//Pos.vy=23*16+1;//16*15;
|
||||||
int colHeight=16;
|
Pos.vy=((Pos.vy+16)&0xfffffff0)-colHeight;
|
||||||
Pos.vy=((Pos.vy-16)&0xfffffff0)+colHeight;
|
|
||||||
|
|
||||||
if(m_moveVel.vy)
|
if(m_moveVel.vy)
|
||||||
{
|
{
|
||||||
// Was falling.. so we've just hit the ground
|
// Was falling.. so we've just hit the ground
|
||||||
if(m_currentState==STATE_BUTTFALL)
|
if(m_currentState==STATE_BUTTFALL)
|
||||||
{
|
{
|
||||||
// landed from a btt bounce
|
// Landed from a butt bounce
|
||||||
setState(STATE_BUTTLAND);
|
setState(STATE_BUTTLAND);
|
||||||
}
|
}
|
||||||
else if(m_currentState==STATE_FALLFAR)
|
else if(m_currentState==STATE_FALLFAR)
|
||||||
{
|
{
|
||||||
// Landed from a painful long fall
|
// Landed from a painfully long fall
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
takeDamage(DAMAGE__FALL);
|
takeDamage(DAMAGE__FALL);
|
||||||
m_moveVel.vx=0;
|
m_moveVel.vx=0;
|
||||||
|
@ -359,7 +361,7 @@ Pos.vy=((Pos.vy-16)&0xfffffff0)+colHeight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Landed from a standing jump
|
// Landed from a jump with no x movement
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
setAnimNo(ANIM_PLAYER_ANIM_JUMPEND);
|
setAnimNo(ANIM_PLAYER_ANIM_JUMPEND);
|
||||||
}
|
}
|
||||||
|
@ -797,7 +799,20 @@ PLAYERINPUT CPlayer::getPadInputDown()
|
||||||
int CPlayer::isOnSolidGround()
|
int CPlayer::isOnSolidGround()
|
||||||
{
|
{
|
||||||
ASSERT(m_layerCollision);
|
ASSERT(m_layerCollision);
|
||||||
return m_layerCollision->Get(Pos.vx>>4,Pos.vy>>4);
|
return m_layerCollision->Get(Pos.vx>>4,(Pos.vy)>>4)?16:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int slip=false;
|
||||||
|
int CPlayer::isOnSlippySurface()
|
||||||
|
{
|
||||||
|
return slip&&isOnSolidGround();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -910,17 +925,48 @@ void CPlayer::moveRight()
|
||||||
void CPlayer::slowdown()
|
void CPlayer::slowdown()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
int stopSpeed;
|
||||||
metrics=getPlayerMetrics();
|
metrics=getPlayerMetrics();
|
||||||
|
if(isOnSlippySurface())
|
||||||
|
{
|
||||||
|
stopSpeed=SLIPSPEED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stopSpeed=0;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_moveVel.vx<0)
|
if(m_moveVel.vx<0)
|
||||||
{
|
{
|
||||||
|
if(-stopSpeed<m_moveVel.vx)
|
||||||
|
{
|
||||||
|
stopSpeed=-m_moveVel.vx;
|
||||||
|
}
|
||||||
m_moveVel.vx+=metrics->m_metric[PM__RUN_SLOWDOWN];
|
m_moveVel.vx+=metrics->m_metric[PM__RUN_SLOWDOWN];
|
||||||
if(m_moveVel.vx>0)m_moveVel.vx=0;
|
if(m_moveVel.vx>-stopSpeed)
|
||||||
|
{
|
||||||
|
m_moveVel.vx=-stopSpeed;
|
||||||
|
if(m_currentState==STATE_RUN)
|
||||||
|
{
|
||||||
|
setState(STATE_IDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(m_moveVel.vx>0)
|
else if(m_moveVel.vx>0)
|
||||||
{
|
{
|
||||||
|
if(stopSpeed>m_moveVel.vx)
|
||||||
|
{
|
||||||
|
stopSpeed=m_moveVel.vx;
|
||||||
|
}
|
||||||
m_moveVel.vx-=metrics->m_metric[PM__RUN_SLOWDOWN];
|
m_moveVel.vx-=metrics->m_metric[PM__RUN_SLOWDOWN];
|
||||||
if(m_moveVel.vx<0)m_moveVel.vx=0;
|
if(m_moveVel.vx<stopSpeed)
|
||||||
|
{
|
||||||
|
m_moveVel.vx=stopSpeed;
|
||||||
|
if(m_currentState==STATE_RUN)
|
||||||
|
{
|
||||||
|
setState(STATE_IDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,11 +157,11 @@ protected:
|
||||||
{
|
{
|
||||||
DEFAULT_PLAYER_JUMP_VELOCITY=4,
|
DEFAULT_PLAYER_JUMP_VELOCITY=4,
|
||||||
DEFAULT_PLAYER_MAX_JUMP_FRAMES=12,
|
DEFAULT_PLAYER_MAX_JUMP_FRAMES=12,
|
||||||
DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES=20,
|
DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES=30,
|
||||||
DEFAULT_PLAYER_MAX_RUN_VELOCITY=8,
|
DEFAULT_PLAYER_MAX_RUN_VELOCITY=8,
|
||||||
DEFAULT_PLAYER_RUN_SPEEDUP=4,
|
DEFAULT_PLAYER_RUN_SPEEDUP=4,
|
||||||
DEFAULT_PLAYER_RUN_REVERSESLOWDOWN=2,
|
DEFAULT_PLAYER_RUN_REVERSESLOWDOWN=3,
|
||||||
DEFAULT_PLAYER_RUN_SLOWDOWN=1,
|
DEFAULT_PLAYER_RUN_SLOWDOWN=2,
|
||||||
PLAYER_GRAVITY=4,
|
PLAYER_GRAVITY=4,
|
||||||
PLAYER_TERMINAL_VELOCITY=8,
|
PLAYER_TERMINAL_VELOCITY=8,
|
||||||
};
|
};
|
||||||
|
@ -186,6 +186,7 @@ protected:
|
||||||
|
|
||||||
// Collision
|
// Collision
|
||||||
int isOnSolidGround();
|
int isOnSolidGround();
|
||||||
|
int isOnSlippySurface();
|
||||||
int isOnEdge();
|
int isOnEdge();
|
||||||
int canMoveLeft();
|
int canMoveLeft();
|
||||||
int canMoveRight();
|
int canMoveRight();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue