This commit is contained in:
parent
dd3fb8cbc8
commit
3d6fc4e5e9
@ -99,6 +99,8 @@ m_animFrame=0;
|
||||
m_cameraOffsetTarget.vy=0;
|
||||
m_cameraOffset.vx=0;
|
||||
m_cameraOffset.vy=0;
|
||||
|
||||
m_lastPadInput=m_padInput=0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
@ -120,12 +122,22 @@ void CPlayer::shutdown()
|
||||
---------------------------------------------------------------------- */
|
||||
DVECTOR ofs={-240,-134}; // nearly -256,-128 ;)
|
||||
int psize=0;
|
||||
int newmode=-1;
|
||||
void CPlayer::think(int _frames)
|
||||
{
|
||||
int i;
|
||||
|
||||
CThing::think(_frames);
|
||||
|
||||
|
||||
if(newmode!=-1)
|
||||
{
|
||||
setMode((PLAYER_MODE)newmode);
|
||||
newmode=-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef __USER_paul__
|
||||
int padInput=PadGetHeld(0);
|
||||
int move=7*_frames;
|
||||
@ -140,6 +152,7 @@ void CPlayer::think(int _frames)
|
||||
for(i=0;i<_frames;i++)
|
||||
{
|
||||
// Think
|
||||
updatePadInput();
|
||||
m_currentStateClass->think(this);
|
||||
|
||||
// Horizontal movement
|
||||
@ -397,9 +410,13 @@ DVECTOR CPlayer::getPlayerPos()
|
||||
{
|
||||
return Pos;
|
||||
}
|
||||
int CPlayer::getPadInput()
|
||||
int CPlayer::getPadInputHeld()
|
||||
{
|
||||
return PadGetHeld(0);
|
||||
return m_padInput;
|
||||
}
|
||||
int CPlayer::getPadInputDown()
|
||||
{
|
||||
return m_padInputDown;
|
||||
}
|
||||
|
||||
|
||||
@ -429,7 +446,6 @@ int CPlayer::isOnSolidGround()
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void CPlayer::moveLeft()
|
||||
{
|
||||
const PlayerMetrics *metrics;
|
||||
@ -493,5 +509,31 @@ void CPlayer::fall()
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayer::updatePadInput()
|
||||
{
|
||||
m_lastPadInput=m_padInput;
|
||||
m_padInput=readPadInput();
|
||||
m_padInputDown=m_padInput&(m_lastPadInput^-1);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CPlayer::readPadInput()
|
||||
{
|
||||
return PadGetHeld(0);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
@ -66,6 +66,7 @@ typedef enum
|
||||
{
|
||||
PLAYER_MODE_BASICUNARMED,
|
||||
PLAYER_MODE_FULLUNARMED,
|
||||
PLAYER_MODE_CORALBLOWER,
|
||||
|
||||
NUM_PLAYERMODES,
|
||||
}PLAYER_MODE;
|
||||
@ -133,7 +134,8 @@ protected:
|
||||
DVECTOR getMoveVelocity();
|
||||
void setMoveVelocity(DVECTOR *_moveVel);
|
||||
DVECTOR getPlayerPos();
|
||||
virtual int getPadInput();
|
||||
int getPadInputHeld();
|
||||
int getPadInputDown();
|
||||
|
||||
// Collision
|
||||
int isOnSolidGround();
|
||||
@ -183,6 +185,12 @@ private:
|
||||
DVECTOR m_cameraOffsetTarget;
|
||||
DVECTOR m_cameraOffset;
|
||||
|
||||
void updatePadInput();
|
||||
virtual int readPadInput();
|
||||
int m_padInput; // Controls that are being held down
|
||||
int m_lastPadInput; // Last frames controls
|
||||
int m_padInputDown; // Controls that were pressed this frame
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,7 +72,8 @@
|
||||
Vars
|
||||
---- */
|
||||
|
||||
CPlayerStateIdle stateIdle;
|
||||
CPlayerStateUnarmedIdle stateUnarmedIdle;
|
||||
CPlayerStateCoralBlowerIdle stateCoralBlowerIdle;
|
||||
CPlayerStateJump stateJump;
|
||||
CPlayerStateRun stateRun;
|
||||
CPlayerStateFall stateFall;
|
||||
@ -113,7 +114,7 @@ CPlayer::PlayerMode CPlayer::s_modes[NUM_PLAYERMODES]=
|
||||
1, // PM__RUN_SLOWDOWN
|
||||
} },
|
||||
{
|
||||
&stateIdle, // STATE_IDLE
|
||||
&stateUnarmedIdle, // STATE_IDLE
|
||||
&stateJump, // STATE_JUMP
|
||||
&stateRun, // STATE_RUN
|
||||
&stateFall, // STATE_FALL
|
||||
@ -146,7 +147,7 @@ CPlayer::PlayerMode CPlayer::s_modes[NUM_PLAYERMODES]=
|
||||
1, // PM__RUN_SLOWDOWN
|
||||
} },
|
||||
{
|
||||
&stateIdle, // STATE_IDLE
|
||||
&stateUnarmedIdle, // STATE_IDLE
|
||||
&stateJump, // STATE_JUMP
|
||||
&stateRun, // STATE_RUN
|
||||
&stateFall, // STATE_FALL
|
||||
@ -161,7 +162,40 @@ CPlayer::PlayerMode CPlayer::s_modes[NUM_PLAYERMODES]=
|
||||
&stateSoackUp, // STATE_SOAKUP
|
||||
&stateGetup, // STATE_GETUP
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Armed with coral blower
|
||||
//
|
||||
{
|
||||
{ {
|
||||
8, // PM__JUMP_VELOCITY
|
||||
10, // PM__MAX_JUMP_FRAMES
|
||||
20, // PM__MAX_SAFE_FALL_FRAMES
|
||||
4, // PM__GRAVITY_VALUE
|
||||
8, // PM__TERMINAL_VELOCITY
|
||||
4,//8, // PM__MAX_RUN_VELOCITY
|
||||
2,//4, // PM__RUN_SPEEDUP
|
||||
2, // PM__RUN_REVERSESLOWDOWN
|
||||
2,//1, // PM__RUN_SLOWDOWN
|
||||
} },
|
||||
{
|
||||
&stateCoralBlowerIdle, // STATE_IDLE
|
||||
NULL, // STATE_JUMP
|
||||
&stateRun, // STATE_RUN
|
||||
&stateFall, // STATE_FALL
|
||||
&stateFallFar, // STATE_FALLFAR
|
||||
NULL, // STATE_BUTTBOUNCE
|
||||
NULL, // STATE_BUTTFALL
|
||||
NULL, // STATE_BUTTLAND
|
||||
NULL, // STATE_ATTACK
|
||||
NULL, // STATE_RUNATTACK
|
||||
NULL, // STATE_AIRATTACK
|
||||
NULL, // STATE_DUCK
|
||||
NULL, // STATE_SOAKUP
|
||||
NULL, // STATE_GETUP
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
@ -90,14 +90,14 @@ void CPlayerStateChop::think(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateRunChop::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
control=getPadInput(_player);
|
||||
int controlHeld;
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
@ -128,14 +128,14 @@ void CPlayerStateRunChop::think(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateAirChop::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
control=getPadInput(_player);
|
||||
int controlHeld;
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
|
@ -111,10 +111,10 @@ void CPlayerStateSoakUp::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateSoakUp::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
int controlHeld;
|
||||
|
||||
control=getPadInput(_player);
|
||||
if(!(control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN)))
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
if(!(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN)))
|
||||
{
|
||||
setState(_player,STATE_GETUP);
|
||||
}
|
||||
|
@ -77,17 +77,17 @@ void CPlayerStateFall::enter(CPlayer *_player)
|
||||
void CPlayerStateFall::think(CPlayer *_player)
|
||||
{
|
||||
const PlayerMetrics *metrics;
|
||||
int control;
|
||||
int controlHeld;
|
||||
DVECTOR move;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
control=getPadInput(_player);
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
@ -96,11 +96,11 @@ void CPlayerStateFall::think(CPlayer *_player)
|
||||
slowdown(_player);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
{
|
||||
setState(_player,STATE_AIRATTACK);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
{
|
||||
move.vx=0;
|
||||
move.vy=0;
|
||||
@ -131,16 +131,16 @@ void CPlayerStateFallFar::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateFallFar::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
DVECTOR move;
|
||||
int controlHeld;
|
||||
DVECTOR move;
|
||||
|
||||
control=getPadInput(_player);
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
|
@ -58,19 +58,6 @@
|
||||
Vars
|
||||
---- */
|
||||
|
||||
CPlayerStateIdle::IdleAnims CPlayerStateIdle::s_idleAnims[]=
|
||||
{
|
||||
// start frame loop frame end frame loop count
|
||||
// { -1, ANIM_PLAYER_ANIM_IDLEGENERIC04, -1, 4 },
|
||||
// { -1, ANIM_PLAYER_ANIM_IDLEGENERIC04, -1, 10 },
|
||||
// { -1, ANIM_PLAYER_ANIM_IDLEGENERIC03, -1, 3 },
|
||||
{ -1, ANIM_PLAYER_ANIM_IDLEBOOTS, -1, 4 },
|
||||
{ -1, ANIM_PLAYER_ANIM_IDLECORAL, -1, 10 },
|
||||
{ -1, ANIM_PLAYER_ANIM_WAKEUP, -1, 1 },
|
||||
};
|
||||
int CPlayerStateIdle::s_numIdleAnims=sizeof(CPlayerStateIdle::s_idleAnims)/sizeof(CPlayerStateIdle::IdleAnims);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
@ -95,27 +82,28 @@ void CPlayerStateIdle::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateIdle::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
control=getPadInput(_player);
|
||||
int controlDown,controlHeld;
|
||||
controlDown=getPadInputDown(_player);
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(advanceAnimFrameAndCheckForEndOfAnim(_player))
|
||||
{
|
||||
setNextIdleAnim(_player);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
if(controlDown&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
{
|
||||
setState(_player,STATE_JUMP);
|
||||
}
|
||||
else if(control&(CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT)|CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT)))
|
||||
else if(controlHeld&(CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT)|CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT)))
|
||||
{
|
||||
setState(_player,STATE_RUN);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
{
|
||||
setState(_player,STATE_ATTACK);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
{
|
||||
setState(_player,STATE_DUCK);
|
||||
}
|
||||
@ -131,9 +119,9 @@ void CPlayerStateIdle::think(CPlayer *_player)
|
||||
void CPlayerStateIdle::setNextIdleAnim(CPlayer *_player)
|
||||
{
|
||||
IdleAnims *anims;
|
||||
int finished=false;
|
||||
int finished=false;
|
||||
|
||||
anims=&s_idleAnims[m_currentIdleAnim];
|
||||
anims=getIdleAnimsDb(m_currentIdleAnim);
|
||||
switch(m_animState)
|
||||
{
|
||||
case ANIMSTATE_START:
|
||||
@ -172,14 +160,14 @@ void CPlayerStateIdle::setNextIdleAnim(CPlayer *_player)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(s_numIdleAnims)
|
||||
if(getNumIdleAnims()>1)
|
||||
{
|
||||
// Randomly choose the next anim to run
|
||||
int lastAnim;
|
||||
lastAnim=m_currentIdleAnim;
|
||||
do
|
||||
{
|
||||
m_currentIdleAnim=getRndRange(s_numIdleAnims);
|
||||
m_currentIdleAnim=getRndRange(getNumIdleAnims());
|
||||
}while(m_currentIdleAnim==lastAnim);
|
||||
}
|
||||
else
|
||||
@ -189,7 +177,7 @@ void CPlayerStateIdle::setNextIdleAnim(CPlayer *_player)
|
||||
}
|
||||
|
||||
// Start playing the anim
|
||||
anims=&s_idleAnims[m_currentIdleAnim];
|
||||
anims=getIdleAnimsDb(m_currentIdleAnim);
|
||||
if(anims->m_startFrame==-1)
|
||||
{
|
||||
// No start anim - go straight into loop
|
||||
@ -211,5 +199,53 @@ void CPlayerStateIdle::setNextIdleAnim(CPlayer *_player)
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
static IdleAnims s_unarmedIdleAnims[]=
|
||||
{
|
||||
// start frame loop frame end frame loop count
|
||||
{ -1, ANIM_PLAYER_ANIM_IDLEBOOTS, -1, 4 },
|
||||
{ -1, ANIM_PLAYER_ANIM_IDLECORAL, -1, 10 },
|
||||
{ -1, ANIM_PLAYER_ANIM_WAKEUP, -1, 1 },
|
||||
};
|
||||
static int s_numUnarmedIdleAnims=sizeof(s_unarmedIdleAnims)/sizeof(IdleAnims);
|
||||
IdleAnims *CPlayerStateUnarmedIdle::getIdleAnimsDb(int _animNo)
|
||||
{
|
||||
ASSERT(_animNo<getNumIdleAnims());
|
||||
return &s_unarmedIdleAnims[_animNo];
|
||||
}
|
||||
int CPlayerStateUnarmedIdle::getNumIdleAnims()
|
||||
{
|
||||
return s_numUnarmedIdleAnims;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
static IdleAnims s_coralBlowerIdleAnims[]=
|
||||
{
|
||||
// start frame loop frame end frame loop count
|
||||
{ -1, ANIM_PLAYER_ANIM_IDLECORAL, -1, 1 },
|
||||
};
|
||||
static int s_numCoralBlowerIdleAnims=sizeof(s_coralBlowerIdleAnims)/sizeof(IdleAnims);
|
||||
IdleAnims *CPlayerStateCoralBlowerIdle::getIdleAnimsDb(int _animNo)
|
||||
{
|
||||
ASSERT(_animNo<getNumIdleAnims());
|
||||
return &s_coralBlowerIdleAnims[_animNo];
|
||||
}
|
||||
int CPlayerStateCoralBlowerIdle::getNumIdleAnims()
|
||||
{
|
||||
return s_numCoralBlowerIdleAnims;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
@ -32,21 +32,22 @@
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int m_startFrame; // Or -1 for none
|
||||
int m_loopFrame; // Must exist
|
||||
int m_endFrame; // Or -1 for none
|
||||
int m_loopCount; // Number of times to run m_loopFrame
|
||||
} IdleAnims;
|
||||
|
||||
|
||||
class CPlayerStateIdle : public CPlayerState
|
||||
{
|
||||
public:
|
||||
void enter(class CPlayer *_player);
|
||||
void think(class CPlayer *_player);
|
||||
virtual void enter(class CPlayer *_player);
|
||||
virtual void think(class CPlayer *_player);
|
||||
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
int m_startFrame; // Or -1 for none
|
||||
int m_loopFrame; // Must exist
|
||||
int m_endFrame; // Or -1 for none
|
||||
int m_loopCount; // Number of times to run m_loopFrame;
|
||||
} IdleAnims;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ANIMSTATE_START,
|
||||
@ -56,13 +57,31 @@ private:
|
||||
|
||||
void setNextIdleAnim(class CPlayer *_player);
|
||||
|
||||
virtual IdleAnims *getIdleAnimsDb(int _animNo)=0;
|
||||
virtual int getNumIdleAnims()=0;
|
||||
|
||||
int m_idleTime; // Number of idle anims that have been started
|
||||
int m_currentIdleAnim;
|
||||
ANIMSTATE m_animState;
|
||||
int m_loopCount; // Number of times to loop middle section of anim
|
||||
};
|
||||
|
||||
|
||||
class CPlayerStateUnarmedIdle : public CPlayerStateIdle
|
||||
{
|
||||
private:
|
||||
virtual IdleAnims *getIdleAnimsDb(int _animNo);
|
||||
virtual int getNumIdleAnims();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CPlayerStateCoralBlowerIdle : public CPlayerStateIdle
|
||||
{
|
||||
private:
|
||||
virtual IdleAnims *getIdleAnimsDb(int _animNo);
|
||||
virtual int getNumIdleAnims();
|
||||
|
||||
static IdleAnims s_idleAnims[];
|
||||
static int s_numIdleAnims;
|
||||
};
|
||||
|
||||
|
||||
|
@ -84,12 +84,12 @@ void CPlayerStateJump::enter(CPlayer *_player)
|
||||
void CPlayerStateJump::think(CPlayer *_player)
|
||||
{
|
||||
const PlayerMetrics *metrics;
|
||||
int control;
|
||||
int controlHeld;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
control=getPadInput(_player);
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(m_jumpFrames<=metrics->m_metric[PM__MAX_JUMP_FRAMES]&&control&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
if(m_jumpFrames<=metrics->m_metric[PM__MAX_JUMP_FRAMES]&&controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
{
|
||||
m_jumpFrames++;
|
||||
}
|
||||
@ -98,15 +98,15 @@ void CPlayerStateJump::think(CPlayer *_player)
|
||||
setState(_player,STATE_FALL);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
{
|
||||
setState(_player,STATE_AIRATTACK);
|
||||
}
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
|
@ -66,8 +66,8 @@
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateRun::enter(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
control=getPadInput(_player);
|
||||
int controlHeld;
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(getMoveVelocity(_player).vx)
|
||||
{
|
||||
@ -78,11 +78,11 @@ void CPlayerStateRun::enter(CPlayer *_player)
|
||||
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTART);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
setFacing(_player,FACING_LEFT);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
setFacing(_player,FACING_RIGHT);
|
||||
}
|
||||
@ -99,27 +99,28 @@ void CPlayerStateRun::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateRun::think(CPlayer *_player)
|
||||
{
|
||||
int control;
|
||||
control=getPadInput(_player);
|
||||
int controlDown,controlHeld;
|
||||
controlDown=getPadInputDown(_player);
|
||||
controlHeld=getPadInputHeld(_player);
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
if(controlDown&CPadConfig::getButton(CPadConfig::PAD_CFG_JUMP))
|
||||
{
|
||||
setState(_player,STATE_JUMP);
|
||||
}
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
{
|
||||
setState(_player,STATE_DUCK);
|
||||
}
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION))
|
||||
{
|
||||
setState(_player,STATE_RUNATTACK);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_LEFT))
|
||||
{
|
||||
moveLeft(_player);
|
||||
}
|
||||
else if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
else if(controlHeld&CPadConfig::getButton(CPadConfig::PAD_CFG_RIGHT))
|
||||
{
|
||||
moveRight(_player);
|
||||
}
|
||||
|
@ -216,9 +216,21 @@ DVECTOR CPlayerState::getPlayerPos(CPlayer *_player)
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CPlayerState::getPadInput(CPlayer *_player)
|
||||
int CPlayerState::getPadInputHeld(CPlayer *_player)
|
||||
{
|
||||
return _player->getPadInput();
|
||||
return _player->getPadInputHeld();
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CPlayerState::getPadInputDown(CPlayer *_player)
|
||||
{
|
||||
return _player->getPadInputDown();
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +54,8 @@ protected:
|
||||
DVECTOR getMoveVelocity(class CPlayer *_player);
|
||||
void setMoveVelocity(class CPlayer *_player,DVECTOR *_moveVel);
|
||||
DVECTOR getPlayerPos(class CPlayer *_player);
|
||||
int getPadInput(class CPlayer *_player);
|
||||
int getPadInputHeld(class CPlayer *_player);
|
||||
int getPadInputDown(class CPlayer *_player);
|
||||
|
||||
int isOnSolidGround(class CPlayer *_player);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user