This commit is contained in:
Paul 2001-04-03 16:47:07 +00:00
parent 04e3ffa7bb
commit a75e84604c
18 changed files with 183 additions and 118 deletions

View File

@ -182,14 +182,6 @@ int MAP2D_CENTRE_X=-256;
int MAP2D_CENTRE_Y=-136;
int MAP2D_BLOCKSTEPSIZE=16;
int CAMERA_SCROLLLIMIT=3;//8; // SB is this many tiles off centre at most
int CAMERA_SCROLLTHRESHOLD=6; // If SB moves when more than this many tiles off-centre, the camera will *always* scroll
int CAMERA_STARTMOVETHRESHOLD=20; // If SB moves faster than this then the camera starts scrolling
int CAMERA_STOPMOVETHRESHOLD=10; // If SB moves slower than this then the camera stops scrolling
int CAMERA_SCROLLSPEED=60; // Speed of the scroll ( 60=1 tile scrolled every 4 and a bit frames )
CPlayerModeBase PLAYERMODE;
CPlayerModeChop PLAYERMODECHOP;
CPlayerModeBalloon PLAYERMODEBALLOON;
@ -254,15 +246,11 @@ m_animFrame=0;
m_cameraOffset.vx=0;
m_cameraOffset.vy=0;
m_cameraScrollDir=0;
m_lastPadInput=m_padInput=PI_NONE;
s_screenPos=128;
//!! m_actorGfx.setAng(512);
//m_actorGfx.setAngInc(678);
setCollisionSize(25,50);
setCollisionCentreOffset(0,-25);
@ -347,32 +335,6 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
// Look around
int pad=getPadInputHeld();
// Camera scroll..
if(m_cameraScrollDir==-1)
{
if(m_cameraScrollPos.vx>-CAMERA_SCROLLLIMIT<<8)
{
m_cameraScrollPos.vx-=CAMERA_SCROLLSPEED;
if(m_cameraScrollPos.vx<-CAMERA_SCROLLLIMIT<<8)
{
m_cameraScrollPos.vx=-CAMERA_SCROLLLIMIT<<8;
m_cameraScrollDir=0;
}
}
}
else if(m_cameraScrollDir==+1)
{
if(m_cameraScrollPos.vx<(CAMERA_SCROLLLIMIT<<8))
{
m_cameraScrollPos.vx+=CAMERA_SCROLLSPEED;
if(m_cameraScrollPos.vx>CAMERA_SCROLLLIMIT<<8)
{
m_cameraScrollPos.vx=CAMERA_SCROLLLIMIT<<8;
m_cameraScrollDir=0;
}
}
}
}
@ -393,25 +355,21 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
{
m_playerScreenGeomPos.vx+=m_cameraPos.vx;
m_cameraPos.vx=0;
m_cameraScrollDir=0;
}
else if(m_cameraPos.vx>m_mapCameraEdges.vx)
{
m_playerScreenGeomPos.vx-=m_mapCameraEdges.vx-m_cameraPos.vx;
m_cameraPos.vx=m_mapCameraEdges.vx;
m_cameraScrollDir=0;
}
if(m_cameraPos.vy<0)
{
m_playerScreenGeomPos.vy+=m_cameraPos.vy;
m_cameraPos.vy=0;
m_cameraScrollDir=0;
}
else if(m_cameraPos.vy>m_mapCameraEdges.vy)
{
m_playerScreenGeomPos.vy-=m_mapCameraEdges.vy-m_cameraPos.vy;
m_cameraPos.vy=m_mapCameraEdges.vy;
m_cameraScrollDir=0;
}
CPlayerThing::think(_frames);

View File

@ -192,7 +192,6 @@ private:
DVECTOR m_playerScreenGeomPos;
DVECTOR m_cameraPos;
int m_cameraScrollDir;
int m_facing;

View File

@ -21,6 +21,27 @@
#include "gfx\sprbank.h"
#endif
// States
#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__PSDUCK_H__
#include "player\psduck.h"
#endif
/* Std Lib
------- */
@ -53,6 +74,24 @@
Vars
---- */
static CPlayerState *s_stateTable[]=
{
&s_stateCoralBlowerIdle, // STATE_IDLE
&s_stateCoralBlowerIdle, // STATE_IDLETEETER
&s_stateJump, // STATE_JUMP
&s_stateWalk, // STATE_RUN
&s_stateFall, // STATE_FALL
&s_stateFallFar, // STATE_FALLFAR
NULL, // STATE_BUTTBOUNCE
NULL, // STATE_BUTTFALL
NULL, // STATE_BUTTLAND
NULL, // STATE_DUCK
NULL, // STATE_SOAKUP
&s_stateGetUp, // STATE_GETUP
};
static PlayerMetrics s_playerMetrics=
{ {
DEFAULT_PLAYER_JUMP_VELOCITY/2, // PM__JUMP_VELOCITY
@ -160,5 +199,16 @@ const struct PlayerMetrics *CPlayerModeCoralBlower::getPlayerMetrics()
return &s_playerMetrics;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CPlayerState **CPlayerModeCoralBlower::getStateTable()
{
return s_stateTable;
}
/*===========================================================================
end */

View File

@ -43,6 +43,9 @@ public:
virtual const struct PlayerMetrics *getPlayerMetrics();
protected:
virtual class CPlayerState **getStateTable();
private:
typedef enum
{

View File

@ -82,33 +82,20 @@
Vars
---- */
static CPlayerStateUnarmedIdle stateUnarmedIdle;
static CPlayerStateTeeterIdle stateTeeterIdle;
static CPlayerStateJump stateJump;
static CPlayerStateRun stateRun;
static CPlayerStateFall stateFall;
static CPlayerStateFallFar stateFallFar;
static CPlayerStateDuck stateDuck;
static CPlayerStateSoakUp stateSoakUp;
static CPlayerStateGetUp stateGetUp;
static CPlayerStateButtBounce stateButtBounce;
static CPlayerStateButtBounceFall stateButtBounceFall;
static CPlayerStateButtBounceLand stateButtBounceLand;
CPlayerState *CPlayerModeBase::s_stateTable[]=
static CPlayerState *s_stateTable[]=
{
&stateUnarmedIdle, // STATE_IDLE
&stateTeeterIdle, // STATE_IDLETEETER
&stateJump, // STATE_JUMP
&stateRun, // STATE_RUN
&stateFall, // STATE_FALL
&stateFallFar, // STATE_FALLFAR
&stateButtBounce, // STATE_BUTTBOUNCE
&stateButtBounceFall, // STATE_BUTTFALL
&stateButtBounceLand, // STATE_BUTTLAND
&stateDuck, // STATE_DUCK
&stateSoakUp, // STATE_SOAKUP
&stateGetUp, // STATE_GETUP
&s_stateUnarmedIdle, // STATE_IDLE
&s_stateTeeterIdle, // STATE_IDLETEETER
&s_stateJump, // STATE_JUMP
&s_stateRun, // STATE_RUN
&s_stateFall, // STATE_FALL
&s_stateFallFar, // STATE_FALLFAR
&s_stateButtBounce, // STATE_BUTTBOUNCE
&s_stateButtBounceFall, // STATE_BUTTFALL
&s_stateButtBounceLand, // STATE_BUTTLAND
&s_stateDuck, // STATE_DUCK
&s_stateSoakUp, // STATE_SOAKUP
&s_stateGetUp, // STATE_GETUP
};
static PlayerMetrics s_playerMetrics=
@ -172,7 +159,7 @@ void CPlayerModeBase::enter()
---------------------------------------------------------------------- */
void CPlayerModeBase::think()
{
s_stateTable[m_currentState]->think(this);
getStateTable()[m_currentState]->think(this);
thinkVerticalMovement();
thinkHorizontalMovement();
@ -274,7 +261,7 @@ void CPlayerModeBase::thinkVerticalMovement()
else if(m_currentState==STATE_FALLFAR)
{
// Landed from a painfully long fall
setState(STATE_IDLE);
setState(STATE_GETUP);
m_player->takeDamage(DAMAGE__FALL);
m_moveVelocity.vx=0;
CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_LAND_AFTER_FALL);
@ -486,7 +473,7 @@ int CPlayerModeBase::setState(int _state)
CPlayerState *nextState;
int ret=false;
nextState=s_stateTable[_state];
nextState=getStateTable()[_state];
if(nextState)
{
m_currentStateClass=nextState;
@ -618,17 +605,6 @@ void CPlayerModeBase::moveLeft()
{
m_moveVelocity.vx-=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
}
/*
if(m_moveVelocity.vx<-CAMERA_STARTMOVETHRESHOLD||m_cameraScrollPos.vx<-CAMERA_SCROLLTHRESHOLD<<8)
{
m_cameraScrollDir=+1;
}
else if(m_moveVelocity.vx>-CAMERA_STOPMOVETHRESHOLD)
{
m_cameraScrollDir=0;
}
*/
}
void CPlayerModeBase::moveRight()
@ -649,17 +625,6 @@ void CPlayerModeBase::moveRight()
{
m_moveVelocity.vx+=metrics->m_metric[PM__RUN_REVERSESLOWDOWN];
}
/*
if(m_moveVelocity.vx>CAMERA_STARTMOVETHRESHOLD||m_cameraScrollPos.vx>CAMERA_SCROLLTHRESHOLD<<8)
{
m_cameraScrollDir=-1;
}
else if(m_moveVelocity.vx<CAMERA_STOPMOVETHRESHOLD)
{
m_cameraScrollDir=0;
}
*/
}
int CPlayerModeBase::slowdown()
{
@ -714,7 +679,16 @@ void CPlayerModeBase::fall()
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CPlayerState **CPlayerModeBase::getStateTable()
{
return s_stateTable;
}
/*===========================================================================
end */

View File

@ -151,7 +151,11 @@ private:
int m_fallFrames;
DVECTOR m_moveVelocity;
static class CPlayerState *s_stateTable[];
protected:
virtual class CPlayerState **getStateTable();
private:
class CPlayerState *m_currentStateClass;
PLAYER_STATE m_currentState;
};

View File

@ -59,6 +59,11 @@
Vars
---- */
CPlayerStateButtBounce s_stateButtBounce;
CPlayerStateButtBounceFall s_stateButtBounceFall;
CPlayerStateButtBounceLand s_stateButtBounceLand;
/*----------------------------------------------------------------------
Function:
Purpose:

View File

@ -63,6 +63,11 @@ private:
Globals
------- */
extern CPlayerStateButtBounce s_stateButtBounce;
extern CPlayerStateButtBounceFall s_stateButtBounceFall;
extern CPlayerStateButtBounceLand s_stateButtBounceLand;
/*----------------------------------------------------------------------
Functions
--------- */

View File

@ -55,6 +55,11 @@
Vars
---- */
CPlayerStateDuck s_stateDuck;
CPlayerStateSoakUp s_stateSoakUp;
CPlayerStateGetUp s_stateGetUp;
/*----------------------------------------------------------------------
Function:
Purpose:

View File

@ -63,6 +63,11 @@ public:
Globals
------- */
extern CPlayerStateDuck s_stateDuck;
extern CPlayerStateSoakUp s_stateSoakUp;
extern CPlayerStateGetUp s_stateGetUp;
/*----------------------------------------------------------------------
Functions
--------- */

View File

@ -54,6 +54,10 @@
Vars
---- */
CPlayerStateFall s_stateFall;
CPlayerStateFallFar s_stateFallFar;
/*----------------------------------------------------------------------
Function:
Purpose:
@ -124,11 +128,19 @@ void CPlayerStateFallFar::enter(CPlayerModeBase *_playerMode)
---------------------------------------------------------------------- */
void CPlayerStateFallFar::think(CPlayerModeBase *_playerMode)
{
int frame;
int controlHeld;
DVECTOR move;
controlHeld=_playerMode->getPadInputHeld();
frame=_playerMode->getAnimFrame();
{
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
{
_playerMode->setAnimFrame(frame);
}
}
controlHeld=_playerMode->getPadInputHeld();
if(controlHeld&PI_LEFT)
{
_playerMode->moveLeft();

View File

@ -54,6 +54,10 @@ private:
Globals
------- */
extern CPlayerStateFall s_stateFall;
extern CPlayerStateFallFar s_stateFallFar;
/*----------------------------------------------------------------------
Functions
--------- */

View File

@ -54,6 +54,10 @@
Vars
---- */
CPlayerStateUnarmedIdle s_stateUnarmedIdle;
CPlayerStateTeeterIdle s_stateTeeterIdle;
CPlayerStateCoralBlowerIdle s_stateCoralBlowerIdle;
/*----------------------------------------------------------------------
Function:
@ -81,10 +85,6 @@ void CPlayerStateBaseIdle::thinkControl(CPlayerModeBase *_playerMode)
if(_playerMode->canMoveRight())
_playerMode->setState(STATE_RUN);
}
else if(controlDown&PI_ACTION)
{
// _playerMode->setState(STATE_ATTACK);
}
else if(controlHeld&PI_DOWN)
{
_playerMode->setState(STATE_DUCK);

View File

@ -107,6 +107,11 @@ private:
Globals
------- */
extern CPlayerStateUnarmedIdle s_stateUnarmedIdle;
extern CPlayerStateTeeterIdle s_stateTeeterIdle;
extern CPlayerStateCoralBlowerIdle s_stateCoralBlowerIdle;
/*----------------------------------------------------------------------
Functions
--------- */

View File

@ -59,6 +59,9 @@
Vars
---- */
CPlayerStateJump s_stateJump;
/*----------------------------------------------------------------------
Function:
Purpose:

View File

@ -48,6 +48,9 @@ private:
Globals
------- */
extern CPlayerStateJump s_stateJump;
/*----------------------------------------------------------------------
Functions
--------- */

View File

@ -33,11 +33,6 @@
/* Data
---- */
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
@ -54,6 +49,10 @@
Vars
---- */
CPlayerStateRun s_stateRun;
CPlayerStateWalk s_stateWalk;
/*----------------------------------------------------------------------
Function:
Purpose:
@ -67,12 +66,17 @@ void CPlayerStateRun::enter(CPlayerModeBase *_playerMode)
if(_playerMode->getMoveVelocity().vx)
{
_playerMode->setAnimNo(ANIM_SPONGEBOB_RUN);
_playerMode->setAnimNo(getLoopFrame());
}
else
{
//!! _playerMode->setAnimNo(ANIM_SPONGEBOB_RUNSTART);
_playerMode->setAnimNo(ANIM_SPONGEBOB_FIRE);
int frame;
frame=getStartFrame();
if(frame==-1)
{
frame=getLoopFrame();
}
_playerMode->setAnimNo(frame);
}
if(controlHeld&PI_LEFT)
@ -84,7 +88,7 @@ void CPlayerStateRun::enter(CPlayerModeBase *_playerMode)
_playerMode->setFacing(FACING_RIGHT);
}
m_numberOfTimeAnimHasLooped=0;
m_numberOfTimesAnimHasLooped=0;
}
@ -125,10 +129,14 @@ void CPlayerStateRun::think(CPlayerModeBase *_playerMode)
if(_playerMode->slowdown())
{
_playerMode->setState(STATE_IDLE);
if(m_numberOfTimeAnimHasLooped>=4)
if(m_numberOfTimesAnimHasLooped>=4)
{
//!! _playerMode->setAnimNo(ANIM_SPONGEBOB_RUNSTOP);
_playerMode->setAnimNo(ANIM_SPONGEBOB_FIRE);
int frame;
frame=getStartFrame();
if(frame!=-1)
{
_playerMode->setAnimNo(getEndFrame());
}
}
return;
}
@ -137,8 +145,8 @@ void CPlayerStateRun::think(CPlayerModeBase *_playerMode)
if(_playerMode->advanceAnimFrameAndCheckForEndOfAnim())
{
_playerMode->setAnimNo(ANIM_SPONGEBOB_RUN);
m_numberOfTimeAnimHasLooped++;
_playerMode->setAnimNo(getLoopFrame());
m_numberOfTimesAnimHasLooped++;
}
}

View File

@ -20,6 +20,10 @@
#include "player\pstates.h"
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
#endif
/* Std Lib
------- */
@ -38,8 +42,22 @@ public:
void enter(class CPlayerModeBase *_playerMode);
void think(class CPlayerModeBase *_playerMode);
protected:
virtual int getStartFrame() {return ANIM_SPONGEBOB_FIRE;}
virtual int getLoopFrame() {return ANIM_SPONGEBOB_RUN;}
virtual int getEndFrame() {return ANIM_SPONGEBOB_FIRE;}
private:
int m_numberOfTimeAnimHasLooped;
int m_numberOfTimesAnimHasLooped;
};
class CPlayerStateWalk : public CPlayerStateRun
{
protected:
virtual int getStartFrame() {return -1;}
virtual int getLoopFrame() {return ANIM_SPONGEBOB_WALK;}
virtual int getEndFrame() {return -1;}
};
@ -47,6 +65,10 @@ private:
Globals
------- */
extern CPlayerStateRun s_stateRun;
extern CPlayerStateWalk s_stateWalk;
/*----------------------------------------------------------------------
Functions
--------- */