This commit is contained in:
parent
cece6ee0fd
commit
991083d6b5
6 changed files with 87 additions and 50 deletions
|
@ -108,7 +108,7 @@
|
||||||
|
|
||||||
// The collision box is this high.. if SB keeps falling through platforms then it *should* be sufficient
|
// The collision box is this high.. if SB keeps falling through platforms then it *should* be sufficient
|
||||||
// just to up this a bit
|
// just to up this a bit
|
||||||
#define PLATFORMCOLLISIONHEIGHT 60
|
#define PLATFORMCOLLISIONHEIGHT 80
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -800,6 +800,7 @@ static int lastposnum=0;
|
||||||
#ifdef __USER_paul__
|
#ifdef __USER_paul__
|
||||||
int mouth=-1,eyes=-1;
|
int mouth=-1,eyes=-1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CPlayer::render()
|
void CPlayer::render()
|
||||||
{
|
{
|
||||||
CPlayerThing::render();
|
CPlayerThing::render();
|
||||||
|
@ -926,11 +927,11 @@ void CPlayer::setMapSize(DVECTOR _mapSize)
|
||||||
int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight)
|
int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight)
|
||||||
{
|
{
|
||||||
int height;
|
int height;
|
||||||
CThing *platform;
|
|
||||||
|
|
||||||
height=height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight);
|
height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight);
|
||||||
if(height<_maxHeight)
|
if(height>=_maxHeight)
|
||||||
{
|
{
|
||||||
|
CThing *platform;
|
||||||
platform=isOnPlatform();
|
platform=isOnPlatform();
|
||||||
if(platform)
|
if(platform)
|
||||||
{
|
{
|
||||||
|
@ -1175,6 +1176,7 @@ void CPlayer::respawn()
|
||||||
m_bubbleAmmo=0;
|
m_bubbleAmmo=0;
|
||||||
m_jellyAmmo=0;
|
m_jellyAmmo=0;
|
||||||
|
|
||||||
|
m_moveVelocity.vx=m_moveVelocity.vy=0;
|
||||||
|
|
||||||
clearPlatform();
|
clearPlatform();
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,6 +183,8 @@ public:
|
||||||
int isRecoveringFromHit() {return m_invincibleFrameCount!=0||m_currentMode==PLAYER_MODE_DEAD;}
|
int isRecoveringFromHit() {return m_invincibleFrameCount!=0||m_currentMode==PLAYER_MODE_DEAD;}
|
||||||
|
|
||||||
void registerAddon(PLAYER_ADDONS _addon);
|
void registerAddon(PLAYER_ADDONS _addon);
|
||||||
|
DVECTOR *getMoveVelocity() {return &m_moveVelocity;}
|
||||||
|
void setMoveVelocity(const DVECTOR *_moveVelocity) {m_moveVelocity=*_moveVelocity;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setMode(PLAYER_MODE _mode);
|
void setMode(PLAYER_MODE _mode);
|
||||||
|
@ -196,6 +198,10 @@ public:
|
||||||
private:
|
private:
|
||||||
void playAnimFrameSfx(int _animNo,int _animFrame);
|
void playAnimFrameSfx(int _animNo,int _animFrame);
|
||||||
|
|
||||||
|
DVECTOR m_moveVelocity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DVECTOR getPlayerPos() {return Pos;}
|
DVECTOR getPlayerPos() {return Pos;}
|
||||||
void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;}
|
void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;}
|
||||||
|
|
|
@ -60,6 +60,11 @@ void CPlayerModeFly::enter()
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
#ifdef __USER_paul__
|
||||||
|
int playerflyspeed=5;
|
||||||
|
#else
|
||||||
|
static const int playerflyspeed=5;
|
||||||
|
#endif
|
||||||
void CPlayerModeFly::think()
|
void CPlayerModeFly::think()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
|
@ -69,19 +74,19 @@ void CPlayerModeFly::think()
|
||||||
controlHeld=getPadInputHeld();
|
controlHeld=getPadInputHeld();
|
||||||
if(controlHeld&PI_LEFT)
|
if(controlHeld&PI_LEFT)
|
||||||
{
|
{
|
||||||
pos.vx-=5;
|
pos.vx-=playerflyspeed;
|
||||||
}
|
}
|
||||||
else if(controlHeld&PI_RIGHT)
|
else if(controlHeld&PI_RIGHT)
|
||||||
{
|
{
|
||||||
pos.vx+=5;
|
pos.vx+=playerflyspeed;
|
||||||
}
|
}
|
||||||
if(controlHeld&PI_UP)
|
if(controlHeld&PI_UP)
|
||||||
{
|
{
|
||||||
pos.vy-=5;
|
pos.vy-=playerflyspeed;
|
||||||
}
|
}
|
||||||
else if(controlHeld&PI_DOWN)
|
else if(controlHeld&PI_DOWN)
|
||||||
{
|
{
|
||||||
pos.vy+=5;
|
pos.vy+=playerflyspeed;
|
||||||
}
|
}
|
||||||
setPlayerPos(&pos);
|
setPlayerPos(&pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ void CPlayerModeBase::enter()
|
||||||
{
|
{
|
||||||
m_fallFrames=0;
|
m_fallFrames=0;
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
m_moveVelocity.vx=m_moveVelocity.vy=0;
|
zeroMoveVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -252,7 +252,7 @@ ATTACK_STATE CPlayerModeBase::getAttackState()
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CPlayerModeBase::thinkVerticalMovement()
|
void CPlayerModeBase::thinkVerticalMovement()
|
||||||
{
|
{
|
||||||
if(m_player->moveVertical(m_moveVelocity.vy>>VELOCITY_SHIFT))
|
if(m_player->moveVertical(m_player->getMoveVelocity()->vy>>VELOCITY_SHIFT))
|
||||||
{
|
{
|
||||||
playerHasHitGround();
|
playerHasHitGround();
|
||||||
}
|
}
|
||||||
|
@ -278,14 +278,18 @@ void CPlayerModeBase::thinkVerticalMovement()
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CPlayerModeBase::thinkHorizontalMovement()
|
void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
{
|
{
|
||||||
if(m_player->moveHorizontal(m_moveVelocity.vx>>VELOCITY_SHIFT))
|
DVECTOR moveVel;
|
||||||
|
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
if(m_player->moveHorizontal(moveVel.vx>>VELOCITY_SHIFT))
|
||||||
{
|
{
|
||||||
// If running then go to idle, otherwise leave in same state
|
// If running then go to idle, otherwise leave in same state
|
||||||
if(m_currentState==STATE_RUN)
|
if(m_currentState==STATE_RUN)
|
||||||
{
|
{
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
}
|
}
|
||||||
m_moveVelocity.vx=0;
|
moveVel.vx=0;
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +301,10 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CPlayerModeBase::playerHasHitGround()
|
void CPlayerModeBase::playerHasHitGround()
|
||||||
{
|
{
|
||||||
// Grrr!
|
DVECTOR moveVel;
|
||||||
m_moveVelocity.vy=0;
|
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
moveVel.vy=0;
|
||||||
m_fallFrames=0;
|
m_fallFrames=0;
|
||||||
if(m_currentState==STATE_BUTTFALL)
|
if(m_currentState==STATE_BUTTFALL)
|
||||||
{
|
{
|
||||||
|
@ -310,9 +316,9 @@ void CPlayerModeBase::playerHasHitGround()
|
||||||
// Landed from a painfully long fall
|
// Landed from a painfully long fall
|
||||||
setState(STATE_HITGROUND);
|
setState(STATE_HITGROUND);
|
||||||
m_player->takeDamage(DAMAGE__FALL);
|
m_player->takeDamage(DAMAGE__FALL);
|
||||||
m_moveVelocity.vx=0;
|
moveVel.vx=0;
|
||||||
}
|
}
|
||||||
else if(m_moveVelocity.vx)
|
else if(moveVel.vx)
|
||||||
{
|
{
|
||||||
// Landed from a jump with x movement
|
// Landed from a jump with x movement
|
||||||
setState(STATE_RUN);
|
setState(STATE_RUN);
|
||||||
|
@ -323,6 +329,7 @@ void CPlayerModeBase::playerHasHitGround()
|
||||||
setState(STATE_IDLE);
|
setState(STATE_IDLE);
|
||||||
setAnimNo(ANIM_SPONGEBOB_JUMPEND);
|
setAnimNo(ANIM_SPONGEBOB_JUMPEND);
|
||||||
}
|
}
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -402,9 +409,9 @@ int CPlayerModeBase::advanceAnimFrameAndCheckForEndOfAnim()
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
DVECTOR CPlayerModeBase::getMoveVelocity() {return m_moveVelocity;}
|
DVECTOR CPlayerModeBase::getMoveVelocity() {return *m_player->getMoveVelocity();}
|
||||||
void CPlayerModeBase::zeroMoveVelocity() {m_moveVelocity.vx=m_moveVelocity.vy=0;}
|
void CPlayerModeBase::zeroMoveVelocity() {DVECTOR v={0,0};setMoveVelocity(&v);}
|
||||||
void CPlayerModeBase::setMoveVelocity(DVECTOR *_moveVel) {m_moveVelocity=*_moveVel;}
|
void CPlayerModeBase::setMoveVelocity(DVECTOR *_moveVel) {m_player->setMoveVelocity(_moveVel);}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
|
@ -476,63 +483,72 @@ void CPlayerModeBase::setPlayerCollisionSize(int _x,int _y,int _w,int _h)
|
||||||
void CPlayerModeBase::moveLeft()
|
void CPlayerModeBase::moveLeft()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
metrics=getPlayerMetrics();
|
DVECTOR moveVel;
|
||||||
|
|
||||||
|
metrics=getPlayerMetrics();
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
setFacing(FACING_LEFT);
|
setFacing(FACING_LEFT);
|
||||||
if(m_moveVelocity.vx<=0)
|
if(moveVel.vx<=0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx-=metrics->m_metric[PM__RUN_SPEEDUP];
|
moveVel.vx-=metrics->m_metric[PM__RUN_SPEEDUP];
|
||||||
if(m_moveVelocity.vx<-metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT)
|
if(moveVel.vx<-metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx=-metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT;
|
moveVel.vx=-metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx-=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
|
moveVel.vx-=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
|
||||||
}
|
}
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerModeBase::moveRight()
|
void CPlayerModeBase::moveRight()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
DVECTOR moveVel;
|
||||||
|
|
||||||
metrics=getPlayerMetrics();
|
metrics=getPlayerMetrics();
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
setFacing(FACING_RIGHT);
|
setFacing(FACING_RIGHT);
|
||||||
if(m_moveVelocity.vx>=0)
|
if(moveVel.vx>=0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx+=metrics->m_metric[PM__RUN_SPEEDUP];
|
moveVel.vx+=metrics->m_metric[PM__RUN_SPEEDUP];
|
||||||
if(m_moveVelocity.vx>metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT)
|
if(moveVel.vx>metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx=metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT;
|
moveVel.vx=metrics->m_metric[PM__MAX_RUN_VELOCITY]<<VELOCITY_SHIFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx+=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
|
moveVel.vx+=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
|
||||||
}
|
}
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
int CPlayerModeBase::slowdown()
|
int CPlayerModeBase::slowdown()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
DVECTOR moveVel;
|
||||||
int ret=false;
|
int ret=false;
|
||||||
metrics=getPlayerMetrics();
|
|
||||||
|
|
||||||
if(m_moveVelocity.vx<0)
|
metrics=getPlayerMetrics();
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
|
||||||
|
if(moveVel.vx<0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx+=metrics->m_metric[PM__RUN_SLOWDOWN];
|
moveVel.vx+=metrics->m_metric[PM__RUN_SLOWDOWN];
|
||||||
if(m_moveVelocity.vx>=0)
|
if(moveVel.vx>=0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx=0;
|
moveVel.vx=0;
|
||||||
ret=true;
|
ret=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(m_moveVelocity.vx>0)
|
else if(moveVel.vx>0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx-=metrics->m_metric[PM__RUN_SLOWDOWN];
|
moveVel.vx-=metrics->m_metric[PM__RUN_SLOWDOWN];
|
||||||
if(m_moveVelocity.vx<=0)
|
if(moveVel.vx<=0)
|
||||||
{
|
{
|
||||||
m_moveVelocity.vx=0;
|
moveVel.vx=0;
|
||||||
ret=true;
|
ret=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,22 +558,28 @@ int CPlayerModeBase::slowdown()
|
||||||
// This should probly be considered a bug.. (pkg)
|
// This should probly be considered a bug.. (pkg)
|
||||||
ret=true;
|
ret=true;
|
||||||
}
|
}
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
void CPlayerModeBase::jump()
|
void CPlayerModeBase::jump()
|
||||||
{
|
{
|
||||||
m_moveVelocity.vy=-getPlayerMetrics()->m_metric[PM__JUMP_VELOCITY]<<VELOCITY_SHIFT;
|
DVECTOR moveVel;
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
moveVel.vy=-getPlayerMetrics()->m_metric[PM__JUMP_VELOCITY]<<VELOCITY_SHIFT;
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
void CPlayerModeBase::fall()
|
void CPlayerModeBase::fall()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
DVECTOR moveVel;
|
||||||
|
|
||||||
metrics=getPlayerMetrics();
|
metrics=getPlayerMetrics();
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
|
||||||
|
moveVel.vy+=getPlayerMetrics()->m_metric[PM__GRAVITY];
|
||||||
m_moveVelocity.vy+=getPlayerMetrics()->m_metric[PM__GRAVITY];
|
if(moveVel.vy>=metrics->m_metric[PM__TERMINAL_VELOCITY]<<VELOCITY_SHIFT)
|
||||||
if(m_moveVelocity.vy>=metrics->m_metric[PM__TERMINAL_VELOCITY]<<VELOCITY_SHIFT)
|
|
||||||
{
|
{
|
||||||
m_moveVelocity.vy=metrics->m_metric[PM__TERMINAL_VELOCITY]<<VELOCITY_SHIFT;
|
moveVel.vy=metrics->m_metric[PM__TERMINAL_VELOCITY]<<VELOCITY_SHIFT;
|
||||||
if(!canFallForever()&&m_currentState!=STATE_FALLFAR)
|
if(!canFallForever()&&m_currentState!=STATE_FALLFAR)
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
@ -569,16 +591,19 @@ void CPlayerModeBase::fall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
int buttfallspeed=9;
|
int buttfallspeed=9;
|
||||||
void CPlayerModeBase::buttFall()
|
void CPlayerModeBase::buttFall()
|
||||||
{
|
{
|
||||||
const PlayerMetrics *metrics;
|
const PlayerMetrics *metrics;
|
||||||
|
DVECTOR moveVel;
|
||||||
|
|
||||||
metrics=getPlayerMetrics();
|
metrics=getPlayerMetrics();
|
||||||
|
moveVel=*m_player->getMoveVelocity();
|
||||||
|
// moveVel.vy=metrics->m_metric[PM__BUTT_FALL_VELOCITY]<<(VELOCITY_SHIFT+1);
|
||||||
// m_moveVelocity.vy=metrics->m_metric[PM__BUTT_FALL_VELOCITY]<<(VELOCITY_SHIFT+1);
|
moveVel.vy=metrics->m_metric[buttfallspeed]<<VELOCITY_SHIFT;
|
||||||
m_moveVelocity.vy=metrics->m_metric[buttfallspeed]<<VELOCITY_SHIFT;
|
setMoveVelocity(&moveVel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fallFrames;
|
int m_fallFrames;
|
||||||
DVECTOR m_moveVelocity;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue