This commit is contained in:
Paul 2001-04-18 16:35:26 +00:00
parent 52c69c25b8
commit 0d6257fec1
5 changed files with 120 additions and 32 deletions

View File

@ -209,7 +209,29 @@ CPlayerMode *CPlayer::s_playerModes[NUM_PLAYERMODES]=
&PLAYERMODEFLY, // PLAYER_MODE_FLY &PLAYERMODEFLY, // PLAYER_MODE_FLY
}; };
int sbanimspeed=0;
// A big bunch of 'temporary' variables for tweaking things
// This #def makes them static under a release build..
#ifdef __VERSION_DEBUG__s
#define pint int
#else
#define pint static const int
#endif
pint sbanimspeed=0;
pint looktimeout=20;
pint lookmaxoffsetup=3*MAP2D_BLOCKSTEPSIZE;
pint lookmaxoffsetdown=6*MAP2D_BLOCKSTEPSIZE;
pint lookspeed=2;
pint lookreturnspeed=5;
pint ledgeTimer=50;
pint ledgeSpeedIn=1;
pint ledgeSpeedOut=3;
pint ledgeShift=1;
pint cammove=2;
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -231,9 +253,6 @@ void CPlayer::init()
m_layerCollision=NULL; m_layerCollision=NULL;
// m_onPlatform = false;
// m_prevOnPlatform = false;
m_actorGfx=CActorPool::GetActor(ACTORS_SPONGEBOB_SBK); m_actorGfx=CActorPool::GetActor(ACTORS_SPONGEBOB_SBK);
for(int i=0;i<NUM_PLAYERMODES;i++) for(int i=0;i<NUM_PLAYERMODES;i++)
@ -254,8 +273,7 @@ m_animFrame=0;
s_screenPos=128; s_screenPos=128;
setCollisionSize(30,60); resetPlayerCollisionSizeToBase();
setCollisionCentreOffset(0,-30);
m_divingHelmet=false; m_divingHelmet=false;
} }
@ -281,18 +299,6 @@ void CPlayer::shutdown()
CPlayerThing::shutdown(); CPlayerThing::shutdown();
} }
int looktimeout=20;
int lookmaxoffsetup=3*MAP2D_BLOCKSTEPSIZE;
int lookmaxoffsetdown=6*MAP2D_BLOCKSTEPSIZE;
int lookspeed=2;
int lookreturnspeed=5;
int ledgeTimer=50;
int ledgeSpeedIn=1;
int ledgeSpeedOut=3;
int ledgeShift=1;
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: Purpose:
@ -300,7 +306,6 @@ int ledgeShift=1;
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int newmode=-1; int newmode=-1;
int cammove=2;
#ifdef _STATE_DEBUG_ #ifdef _STATE_DEBUG_
char posBuf[100]; char posBuf[100];
@ -357,7 +362,7 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
// Look around // Look around
int pad=getPadInputHeld(); int pad=getPadInputHeld();
if(pad&PI_UP) if(pad&PI_UP&&canDoLookAround())
{ {
if(m_padLookAroundTimer>0) if(m_padLookAroundTimer>0)
{ {
@ -376,7 +381,7 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
} }
} }
} }
else if(pad&PI_DOWN) else if(pad&PI_DOWN&&canDoLookAround())
{ {
if(m_padLookAroundTimer<0) if(m_padLookAroundTimer<0)
{ {
@ -726,6 +731,7 @@ ATTACK_STATE CPlayer::getAttackState()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayer::setMode(PLAYER_MODE _mode) void CPlayer::setMode(PLAYER_MODE _mode)
{ {
resetPlayerCollisionSizeToBase();
m_currentMode=_mode; m_currentMode=_mode;
m_currentPlayerModeClass=s_playerModes[_mode]; m_currentPlayerModeClass=s_playerModes[_mode];
m_currentPlayerModeClass->enter(); m_currentPlayerModeClass->enter();
@ -862,6 +868,17 @@ void CPlayer::renderSb(DVECTOR *_pos,int _animNo,int _animFrame)
} }
/*----------------------------------------------------------------------
Function:
Purpose: Says whether SB can do the look up/down thing
Params:
Returns:
---------------------------------------------------------------------- */
int CPlayer::canDoLookAround()
{
return m_currentPlayerModeClass->canDoLookAround();
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: Purpose:
@ -1116,5 +1133,28 @@ bool CPlayer::getHasPlatformCollided()
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayer::resetPlayerCollisionSizeToBase()
{
setPlayerCollisionSize(0,-COLSIZE_BASE_HEIGHT/2,COLSIZE_BASE_WIDTH,COLSIZE_BASE_HEIGHT);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayer::setPlayerCollisionSize(int _x,int _y,int _w,int _h)
{
setCollisionSize(_w,_h);
setCollisionCentreOffset(_x,_y);
}
/*=========================================================================== /*===========================================================================
end */ end */

View File

@ -196,6 +196,9 @@ public:
CSoundMediator::SFXID m_sfxId; CSoundMediator::SFXID m_sfxId;
} AnimFrameSfx; } AnimFrameSfx;
void renderSb(DVECTOR *_pos,int _animNo,int _animFrame); void renderSb(DVECTOR *_pos,int _animNo,int _animFrame);
int canDoLookAround();
private: private:
typedef struct typedef struct
{ {
@ -291,18 +294,24 @@ public:
private: private:
CThing *m_platform; CThing *m_platform;
/*
private:
CThing *m_platform;
bool m_onPlatform;
bool m_prevOnPlatform;
DVECTOR m_prevPlatformPos;
*/
private: private:
bool m_hasPlatformCollided; bool m_hasPlatformCollided;
// Player collision size
public:
enum
{
COLSIZE_BASE_WIDTH=30,
COLSIZE_BASE_HEIGHT=60,
};
void resetPlayerCollisionSizeToBase();
void setPlayerCollisionSize(int _x,int _y,int _w,int _h);
// Graphical resources // Graphical resources
public: public:
class FontBank *getFontBank() {return m_fontBank;} class FontBank *getFontBank() {return m_fontBank;}

View File

@ -183,8 +183,32 @@ void CPlayerModeBase::think()
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayerModeBase::render() int CPlayerModeBase::canDoLookAround()
{ {
int ret=false;
switch(getState())
{
case STATE_IDLE:
case STATE_IDLETEETER:
case STATE_SOAKUP:
ret=true;
break;
case STATE_JUMP:
case STATE_RUN:
case STATE_FALL:
case STATE_FALLFAR:
case STATE_HITGROUND:
case STATE_BUTTBOUNCE:
case STATE_BUTTFALL:
case STATE_BUTTLAND:
case STATE_DUCK:
case STATE_GETUP:
break;
}
return ret;
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -458,6 +482,7 @@ int CPlayerModeBase::setState(int _state)
nextState=getStateTable()[_state]; nextState=getStateTable()[_state];
if(nextState) if(nextState)
{ {
m_player->resetPlayerCollisionSizeToBase();
m_currentStateClass=nextState; m_currentStateClass=nextState;
m_currentStateClass->enter(this); m_currentStateClass->enter(this);
m_currentState=(PLAYER_STATE)_state; m_currentState=(PLAYER_STATE)_state;
@ -563,6 +588,17 @@ int CPlayerModeBase::canMoveRight()
return m_player->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false; return m_player->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false;
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeBase::setPlayerCollisionSize(int _x,int _y,int _w,int _h)
{
m_player->setPlayerCollisionSize(_x,_y,_w,_h);
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: Purpose:

View File

@ -84,6 +84,8 @@ public:
virtual void think() {;} virtual void think() {;}
virtual void render(DVECTOR *_pos) {;} virtual void render(DVECTOR *_pos) {;}
virtual void renderModeUi() {;} // Ui specific to this mode (eg: ammo) virtual void renderModeUi() {;} // Ui specific to this mode (eg: ammo)
virtual int canDoLookAround() {return false;}
int getPadInputHeld(); int getPadInputHeld();
int getPadInputDown(); int getPadInputDown();
@ -112,7 +114,8 @@ public:
virtual void enter(); virtual void enter();
virtual void think(); virtual void think();
virtual void render(); virtual void render() {;}
virtual int canDoLookAround();
virtual ATTACK_STATE getAttackState(); virtual ATTACK_STATE getAttackState();
@ -127,7 +130,6 @@ public:
virtual const struct PlayerMetrics *getPlayerMetrics(); virtual const struct PlayerMetrics *getPlayerMetrics();
virtual int setState(int _state); virtual int setState(int _state);
int getState() {return m_currentState;} int getState() {return m_currentState;}
// virtual void setMode(class CPlayer *_player,int _mode);
int getFacing(); int getFacing();
void setFacing(int _facing); void setFacing(int _facing);
virtual int getAnimNo(); virtual int getAnimNo();
@ -136,13 +138,13 @@ public:
virtual int getAnimFrame(); virtual int getAnimFrame();
virtual int getAnimFrameCount(); virtual int getAnimFrameCount();
int advanceAnimFrameAndCheckForEndOfAnim(); int advanceAnimFrameAndCheckForEndOfAnim();
// virtual int retreatAnimFrameAndCheckForEndOfAnim(class CPlayer *_player);
DVECTOR getMoveVelocity(); DVECTOR getMoveVelocity();
void zeroMoveVelocity(); void zeroMoveVelocity();
void setMoveVelocity(DVECTOR *_moveVel); void setMoveVelocity(DVECTOR *_moveVel);
int isOnEdge(); int isOnEdge();
int canMoveLeft(); int canMoveLeft();
int canMoveRight(); int canMoveRight();
void setPlayerCollisionSize(int _x,int _y,int _w,int _h);
void moveLeft(); void moveLeft();
void moveRight(); void moveRight();

View File

@ -98,6 +98,7 @@ void CPlayerStateSoakUp::enter(CPlayerModeBase *_playerMode)
{ {
_playerMode->zeroMoveVelocity(); _playerMode->zeroMoveVelocity();
_playerMode->setAnimNo(ANIM_SPONGEBOB_GETUP); _playerMode->setAnimNo(ANIM_SPONGEBOB_GETUP);
_playerMode->setPlayerCollisionSize(0,-10,60,20);
} }