This commit is contained in:
parent
76e5b7a4a2
commit
be932989e6
6 changed files with 74 additions and 96 deletions
|
@ -135,6 +135,7 @@ paul_src := paul \
|
|||
scenesel
|
||||
|
||||
player_src := player \
|
||||
pmodes \
|
||||
psbutt \
|
||||
pschop \
|
||||
psduck \
|
||||
|
|
|
@ -25,38 +25,6 @@
|
|||
#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__PSIDLE_H__
|
||||
#include "player\psidle.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
|
||||
|
@ -92,54 +60,6 @@
|
|||
Vars
|
||||
---- */
|
||||
|
||||
CPlayerStateIdle stateIdle;
|
||||
CPlayerStateJump stateJump;
|
||||
CPlayerStateRun stateRun;
|
||||
CPlayerStateFall stateFall;
|
||||
CPlayerStateFallFar stateFallFar;
|
||||
CPlayerStateButtBounce stateButtBounce;
|
||||
CPlayerStateButtBounceFall stateButtBounceFall;
|
||||
CPlayerStateButtBounceLand stateButtBounceLand;
|
||||
CPlayerStateChop stateChop;
|
||||
CPlayerStateRunChop stateRunChop;
|
||||
CPlayerStateAirChop stateAirChop;
|
||||
CPlayerStateDuck stateDuck;
|
||||
CPlayerStateSoakUp stateSoackUp;
|
||||
CPlayerStateGetUp stateGetup;
|
||||
|
||||
// Player with karate chop installed
|
||||
CPlayer::PlayerMode CPlayer::s_modes=
|
||||
{
|
||||
{ {
|
||||
8, // PM__JUMP_VELOCITY
|
||||
10, // PM__MAX_JUMP_FRAMES
|
||||
20, // PM__MAX_SAFE_FALL_FRAMES
|
||||
4, // PM__GRAVITY_VALUE
|
||||
8, // PM__TERMINAL_VELOCITY
|
||||
8, // PM__MAX_RUN_VELOCITY
|
||||
4, // PM__RUN_SPEEDUP
|
||||
2, // PM__RUN_REVERSESLOWDOWN
|
||||
1, // PM__RUN_SLOWDOWN
|
||||
} },
|
||||
{
|
||||
&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_ATTACK
|
||||
&stateRunChop, // STATE_RUNATTACK
|
||||
&stateAirChop, // STATE_AIRATTACK
|
||||
&stateDuck, // STATE_DUCK
|
||||
&stateSoackUp, // STATE_SOAKUP
|
||||
&stateGetup, // STATE_GETUP
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -157,6 +77,7 @@ void CPlayer::init()
|
|||
|
||||
m_animNo=0;
|
||||
m_animFrame=0;
|
||||
m_currentMode=PLAYER_MODE_BASICUNARMED;
|
||||
setState(STATE_IDLE);
|
||||
m_moveVel.vx=0;
|
||||
m_moveVel.vy=0;
|
||||
|
@ -198,6 +119,7 @@ void CPlayer::shutdown()
|
|||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
DVECTOR ofs={-240,-134}; // nearly -256,-128 ;)
|
||||
int psize=0;
|
||||
void CPlayer::think(int _frames)
|
||||
{
|
||||
int i;
|
||||
|
@ -218,17 +140,17 @@ void CPlayer::think(int _frames)
|
|||
for(i=0;i<_frames;i++)
|
||||
{
|
||||
// Think
|
||||
m_currentState->think(this);
|
||||
m_currentStateClass->think(this);
|
||||
|
||||
// Horizontal movement
|
||||
Pos.vx+=m_moveVel.vx>>VELOCITY_SHIFT;
|
||||
if(Pos.vx<350)
|
||||
{
|
||||
if(m_state==STATE_RUN)
|
||||
{
|
||||
setState(STATE_IDLE);
|
||||
setAnimNo(ANIM_PLAYER_ANIM_RUNSTOP);
|
||||
}
|
||||
// if(m_currentState==STATE_RUN)
|
||||
// {
|
||||
// setState(STATE_IDLE);
|
||||
// setAnimNo(ANIM_PLAYER_ANIM_RUNSTOP);
|
||||
// }
|
||||
Pos.vx=350;
|
||||
m_moveVel.vx=0;
|
||||
}
|
||||
|
@ -240,11 +162,11 @@ void CPlayer::think(int _frames)
|
|||
if(m_moveVel.vy)
|
||||
{
|
||||
// Was falling.. so we've just hit the ground
|
||||
if(m_state==STATE_BUTTFALL)
|
||||
if(m_currentState==STATE_BUTTFALL)
|
||||
{
|
||||
setState(STATE_BUTTLAND);
|
||||
}
|
||||
else if(m_state==STATE_FALLFAR)
|
||||
else if(m_currentState==STATE_FALLFAR)
|
||||
{
|
||||
setState(STATE_IDLE);
|
||||
}
|
||||
|
@ -264,7 +186,7 @@ void CPlayer::think(int _frames)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(m_state!=STATE_JUMP&&m_state!=STATE_BUTTBOUNCE)
|
||||
if(m_currentState!=STATE_JUMP&&m_currentState!=STATE_BUTTBOUNCE)
|
||||
{
|
||||
// Fall
|
||||
const PlayerMetrics *metrics;
|
||||
|
@ -372,7 +294,7 @@ DVECTOR CPlayer::getCameraPos()
|
|||
---------------------------------------------------------------------- */
|
||||
const PlayerMetrics *CPlayer::getPlayerMetrics()
|
||||
{
|
||||
return &s_modes.m_metrics;
|
||||
return &s_modes[m_currentMode].m_metrics;
|
||||
}
|
||||
|
||||
|
||||
|
@ -387,9 +309,28 @@ const PlayerMetrics *CPlayer::getPlayerMetrics()
|
|||
---------------------------------------------------------------------- */
|
||||
void CPlayer::setState(PLAYER_STATE _state)
|
||||
{
|
||||
m_currentState=s_modes.m_states[_state];
|
||||
m_currentState->enter(this);
|
||||
m_state=_state;
|
||||
CPlayerState *nextState;
|
||||
|
||||
nextState=s_modes[m_currentMode].m_states[_state];
|
||||
if(nextState)
|
||||
{
|
||||
m_currentStateClass=nextState;
|
||||
m_currentStateClass->enter(this);
|
||||
m_currentState=_state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayer::setMode(PLAYER_MODE _mode)
|
||||
{
|
||||
m_currentMode=_mode;
|
||||
setState(m_currentState);
|
||||
}
|
||||
|
||||
|
||||
|
@ -452,6 +393,10 @@ void CPlayer::setMoveVelocity(DVECTOR *_moveVel)
|
|||
{
|
||||
m_moveVel=*_moveVel;
|
||||
}
|
||||
DVECTOR CPlayer::getPlayerPos()
|
||||
{
|
||||
return Pos;
|
||||
}
|
||||
int CPlayer::getPadInput()
|
||||
{
|
||||
return PadGetHeld(0);
|
||||
|
|
|
@ -62,6 +62,14 @@ typedef enum
|
|||
NUM_STATES,
|
||||
}PLAYER_STATE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PLAYER_MODE_BASICUNARMED,
|
||||
PLAYER_MODE_FULLUNARMED,
|
||||
|
||||
NUM_PLAYERMODES,
|
||||
}PLAYER_MODE;
|
||||
|
||||
enum
|
||||
{
|
||||
FACING_LEFT=+1,
|
||||
|
@ -114,6 +122,7 @@ protected:
|
|||
|
||||
// State
|
||||
void setState(PLAYER_STATE _state);
|
||||
void setMode(PLAYER_MODE _mode);
|
||||
int getFacing();
|
||||
void setFacing(int _facing);
|
||||
int getAnimFrame();
|
||||
|
@ -123,6 +132,7 @@ protected:
|
|||
void setAnimNo(int _animNo);
|
||||
DVECTOR getMoveVelocity();
|
||||
void setMoveVelocity(DVECTOR *_moveVel);
|
||||
DVECTOR getPlayerPos();
|
||||
virtual int getPadInput();
|
||||
|
||||
// Collision
|
||||
|
@ -147,11 +157,9 @@ private:
|
|||
class CPlayerState *m_states[NUM_STATES];
|
||||
}PlayerMode;
|
||||
|
||||
static PlayerMode s_modes;
|
||||
|
||||
int m_animFrame;
|
||||
int m_animNo;
|
||||
PLAYER_STATE m_state;
|
||||
CSkel m_skel;
|
||||
|
||||
DVECTOR m_moveVel;
|
||||
|
@ -165,7 +173,10 @@ private:
|
|||
};
|
||||
int m_invincibleFrameCount;
|
||||
|
||||
class CPlayerState *m_currentState;
|
||||
static PlayerMode s_modes[NUM_PLAYERMODES];
|
||||
int m_currentMode;
|
||||
class CPlayerState *m_currentStateClass;
|
||||
PLAYER_STATE m_currentState;
|
||||
|
||||
int m_lives;
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include "pad\pads.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAMEBUBS_H__
|
||||
#include "game\gamebubs.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
@ -90,6 +94,10 @@ void CPlayerStateButtBounce::think(CPlayer *_player)
|
|||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateButtBounceLand::enter(CPlayer *_player)
|
||||
{
|
||||
DVECTOR pos;
|
||||
|
||||
pos=getPlayerPos(_player);
|
||||
CGameBubicleFactory::spawnBubicles(pos.vx,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM);
|
||||
setAnimNo(_player,ANIM_PLAYER_ANIM_BUTTBOUNCE);
|
||||
}
|
||||
|
||||
|
|
|
@ -198,6 +198,18 @@ void CPlayerState::setMoveVelocity(CPlayer *_player,DVECTOR *_moveVel)
|
|||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
DVECTOR CPlayerState::getPlayerPos(CPlayer *_player)
|
||||
{
|
||||
return _player->getPlayerPos();
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
|
|
@ -53,6 +53,7 @@ protected:
|
|||
int retreatAnimFrameAndCheckForEndOfAnim(class CPlayer *_player);
|
||||
DVECTOR getMoveVelocity(class CPlayer *_player);
|
||||
void setMoveVelocity(class CPlayer *_player,DVECTOR *_moveVel);
|
||||
DVECTOR getPlayerPos(class CPlayer *_player);
|
||||
int getPadInput(class CPlayer *_player);
|
||||
|
||||
int isOnSolidGround(class CPlayer *_player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue