This commit is contained in:
parent
cef0e7cf12
commit
f950684bc2
@ -25,6 +25,37 @@
|
||||
#include "pad\pads.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSSTATES_H__
|
||||
#include "player\pstates.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSJUMP_H__
|
||||
#include "player\psjump.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSRUN_H__
|
||||
#include "player\psrun.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSFALL_H__
|
||||
#include "player\psfall.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSBUTT_H__
|
||||
#include "player\psbutt.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSCHOP_H__
|
||||
#include "player\pschop.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER__PSDUCK_H__
|
||||
#include "player\psduck.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAMESLOT_H__
|
||||
#include "game\gameslot.h"
|
||||
#endif
|
||||
|
||||
// to be removed
|
||||
#include "gfx\tpage.h"
|
||||
@ -52,19 +83,6 @@
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
#include "player\pstates.h"
|
||||
#include "player\psjump.h"
|
||||
#include "player\psrun.h"
|
||||
#include "player\psfall.h"
|
||||
#include "player\psbutt.h"
|
||||
#include "player\pschop.h"
|
||||
#include "player\psduck.h"
|
||||
CPlayerStateIdle stateIdle;
|
||||
CPlayerStateJump stateJump;
|
||||
CPlayerStateRun stateRun;
|
||||
@ -79,7 +97,30 @@ CPlayerStateDuck stateDuck;
|
||||
CPlayerStateSoakUp stateSoackUp;
|
||||
CPlayerStateGetUp stateGetup;
|
||||
|
||||
CPlayerState *CPlayer::s_states[NUM_STATES]=
|
||||
{
|
||||
&stateIdle, // STATE_IDLE
|
||||
&stateJump, // STATE_JUMP
|
||||
&stateRun, // STATE_RUN
|
||||
&stateFall, // STATE_FALL
|
||||
&stateFallFar, // STATE_FALLFAR
|
||||
&stateButtBounce, // STATE_BUTTBOUNCE
|
||||
&stateButtBounceFall, // STATE_BUTTFALL
|
||||
&stateButtBounceLand, // STATE_BUTTLAND
|
||||
&stateChop, // STATE_CHOP
|
||||
&stateRunChop, // STATE_RUNCHOP
|
||||
&stateDuck, // STATE_DUCK
|
||||
&stateSoackUp, // STATE_SOAKUP
|
||||
&stateGetup, // STATE_GETUP
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayer::init()
|
||||
{
|
||||
CThing::init();
|
||||
@ -96,6 +137,10 @@ m_animFrame=0;
|
||||
m_moveVel.vy=0;
|
||||
setFacing(FACING_RIGHT);
|
||||
|
||||
m_lives=CGameSlotManager::getSlotData().m_lives;
|
||||
|
||||
m_invincibleFrameCount=INVIBCIBLE_FRAMES__START;
|
||||
|
||||
#ifdef __USER_paul__
|
||||
Pos.vx=50;
|
||||
Pos.vy=200;
|
||||
@ -164,6 +209,11 @@ void CPlayer::think(int _frames)
|
||||
}
|
||||
m_moveVel.vy=0;
|
||||
}
|
||||
|
||||
if(m_invincibleFrameCount)
|
||||
{
|
||||
m_invincibleFrameCount--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(Pos.vx<0)Pos.vx=0;
|
||||
@ -177,18 +227,23 @@ void CPlayer::think(int _frames)
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int panim=-1;
|
||||
int MASK=2;
|
||||
void CPlayer::render()
|
||||
{
|
||||
CThing::render();
|
||||
|
||||
// Render
|
||||
m_skel.setFrame(m_animFrame);
|
||||
if(panim!=-1)
|
||||
m_skel.setAnimNo(panim);
|
||||
else
|
||||
m_skel.setAnimNo(m_animNo);
|
||||
m_skel.Animate(this);
|
||||
m_skel.Render(this);
|
||||
if(m_invincibleFrameCount==0||
|
||||
m_invincibleFrameCount&MASK)
|
||||
{
|
||||
m_skel.setFrame(m_animFrame);
|
||||
if(panim!=-1)
|
||||
m_skel.setAnimNo(panim);
|
||||
else
|
||||
m_skel.setAnimNo(m_animNo);
|
||||
m_skel.Animate(this);
|
||||
m_skel.Render(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +271,7 @@ PlayerMetrics s_normalPlayerMetrics=
|
||||
1, // PM__RUN_SLOWDOWN
|
||||
}
|
||||
};
|
||||
PlayerMetrics *CPlayer::getPlayerMetrics()
|
||||
const PlayerMetrics *CPlayer::getPlayerMetrics()
|
||||
{
|
||||
return &s_normalPlayerMetrics;
|
||||
}
|
||||
@ -231,23 +286,6 @@ PlayerMetrics *CPlayer::getPlayerMetrics()
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
CPlayerState *CPlayer::s_states[NUM_STATES]=
|
||||
{
|
||||
&stateIdle, // STATE_IDLE
|
||||
&stateJump, // STATE_JUMP
|
||||
&stateRun, // STATE_RUN
|
||||
&stateFall, // STATE_FALL
|
||||
&stateFallFar, // STATE_FALLFAR
|
||||
&stateButtBounce, // STATE_BUTTBOUNCE
|
||||
&stateButtBounceFall, // STATE_BUTTFALL
|
||||
&stateButtBounceLand, // STATE_BUTTLAND
|
||||
&stateChop, // STATE_CHOP
|
||||
&stateRunChop, // STATE_RUNCHOP
|
||||
&stateDuck, // STATE_DUCK
|
||||
&stateSoackUp, // STATE_SOAKUP
|
||||
&stateGetup, // STATE_GETUP
|
||||
};
|
||||
|
||||
void CPlayer::setState(PLAYER_STATE _state)
|
||||
{
|
||||
m_currentState=s_states[_state];
|
||||
@ -345,7 +383,7 @@ int CPlayer::isOnSolidGround()
|
||||
|
||||
void CPlayer::moveLeft()
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
const PlayerMetrics *metrics;
|
||||
metrics=getPlayerMetrics();
|
||||
|
||||
setFacing(FACING_LEFT);
|
||||
@ -364,7 +402,7 @@ void CPlayer::moveLeft()
|
||||
}
|
||||
void CPlayer::moveRight()
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
const PlayerMetrics *metrics;
|
||||
metrics=getPlayerMetrics();
|
||||
|
||||
setFacing(FACING_RIGHT);
|
||||
@ -383,7 +421,7 @@ void CPlayer::moveRight()
|
||||
}
|
||||
void CPlayer::slowdown()
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
const PlayerMetrics *metrics;
|
||||
metrics=getPlayerMetrics();
|
||||
|
||||
if(m_moveVel.vx<0)
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
void render();
|
||||
|
||||
protected:
|
||||
PlayerMetrics *getPlayerMetrics();
|
||||
const PlayerMetrics *getPlayerMetrics();
|
||||
|
||||
void setState(PLAYER_STATE _state);
|
||||
int getFacing();
|
||||
@ -143,10 +143,21 @@ private:
|
||||
DVECTOR m_moveVel;
|
||||
int m_facing;
|
||||
|
||||
enum
|
||||
{
|
||||
INVIBCIBLE_FRAMES__START=120, // Invincible for this many frames at start of life
|
||||
INVINCIBLE_FRAMES__HIT=25, // Invincible for this many frames after taking damage
|
||||
};
|
||||
int m_invincibleFrameCount;
|
||||
|
||||
static class CPlayerState *s_states[NUM_STATES];
|
||||
|
||||
class CPlayerState *m_currentState;
|
||||
|
||||
|
||||
|
||||
int m_lives;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -103,9 +103,9 @@ void CPlayerStateButtBounceFall::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateButtBounceFall::think(CPlayer *_player)
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
int control;
|
||||
DVECTOR move;
|
||||
const PlayerMetrics *metrics;
|
||||
int control;
|
||||
DVECTOR move;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
control=getPadInput(_player);
|
||||
|
@ -103,22 +103,19 @@ void CPlayerStateRunChop::think(CPlayer *_player)
|
||||
}
|
||||
else
|
||||
{
|
||||
DVECTOR move;
|
||||
move=getMoveVelocity(_player);
|
||||
if(move.vx==0)
|
||||
{
|
||||
setState(_player,STATE_IDLE);
|
||||
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
slowdown(_player);
|
||||
}
|
||||
slowdown(_player);
|
||||
}
|
||||
|
||||
if(advanceAnimFrameAndCheckForEndOfAnim(_player))
|
||||
{
|
||||
setState(_player,STATE_RUN);
|
||||
if(getMoveVelocity(_player).vx==0)
|
||||
{
|
||||
setState(_player,STATE_IDLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
setState(_player,STATE_RUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ void CPlayerStateFall::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateFall::think(CPlayer *_player)
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
int control;
|
||||
DVECTOR move;
|
||||
const PlayerMetrics *metrics;
|
||||
int control;
|
||||
DVECTOR move;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
control=getPadInput(_player);
|
||||
@ -111,7 +111,7 @@ void CPlayerStateFall::think(CPlayer *_player)
|
||||
slowdown(_player);
|
||||
}
|
||||
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_ACTION)&&control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
if(control&CPadConfig::getButton(CPadConfig::PAD_CFG_DOWN))
|
||||
{
|
||||
move.vx=0;
|
||||
move.vy=0;
|
||||
|
@ -63,7 +63,7 @@
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateJump::enter(CPlayer *_player)
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
const PlayerMetrics *metrics;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
|
||||
@ -83,8 +83,8 @@ void CPlayerStateJump::enter(CPlayer *_player)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateJump::think(CPlayer *_player)
|
||||
{
|
||||
PlayerMetrics *metrics;
|
||||
int control;
|
||||
const PlayerMetrics *metrics;
|
||||
int control;
|
||||
|
||||
metrics=getPlayerMetrics(_player);
|
||||
control=getPadInput(_player);
|
||||
|
@ -122,9 +122,7 @@ void CPlayerStateRun::think(CPlayer *_player)
|
||||
}
|
||||
else
|
||||
{
|
||||
DVECTOR move;
|
||||
move=getMoveVelocity(_player);
|
||||
if(move.vx==0)
|
||||
if(getMoveVelocity(_player).vx==0)
|
||||
{
|
||||
setState(_player,STATE_IDLE);
|
||||
setAnimNo(_player,ANIM_PLAYER_ANIM_RUNSTOP);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
PlayerMetrics *CPlayerState::getPlayerMetrics(CPlayer *_player)
|
||||
const PlayerMetrics *CPlayerState::getPlayerMetrics(CPlayer *_player)
|
||||
{
|
||||
return _player->getPlayerMetrics();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
struct PlayerMetrics *getPlayerMetrics(class CPlayer *_player);
|
||||
const struct PlayerMetrics *getPlayerMetrics(class CPlayer *_player);
|
||||
void setState(class CPlayer *_player,int _state);
|
||||
int getFacing(class CPlayer *_player);
|
||||
void setFacing(class CPlayer *_player,int _facing);
|
||||
|
Loading…
Reference in New Issue
Block a user