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_CENTRE_Y=-136;
int MAP2D_BLOCKSTEPSIZE=16; 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; CPlayerModeBase PLAYERMODE;
CPlayerModeChop PLAYERMODECHOP; CPlayerModeChop PLAYERMODECHOP;
CPlayerModeBalloon PLAYERMODEBALLOON; CPlayerModeBalloon PLAYERMODEBALLOON;
@ -254,15 +246,11 @@ m_animFrame=0;
m_cameraOffset.vx=0; m_cameraOffset.vx=0;
m_cameraOffset.vy=0; m_cameraOffset.vy=0;
m_cameraScrollDir=0;
m_lastPadInput=m_padInput=PI_NONE; m_lastPadInput=m_padInput=PI_NONE;
s_screenPos=128; s_screenPos=128;
//!! m_actorGfx.setAng(512);
//m_actorGfx.setAngInc(678);
setCollisionSize(25,50); setCollisionSize(25,50);
setCollisionCentreOffset(0,-25); setCollisionCentreOffset(0,-25);
@ -347,32 +335,6 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
// Look around // Look around
int pad=getPadInputHeld(); 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_playerScreenGeomPos.vx+=m_cameraPos.vx;
m_cameraPos.vx=0; m_cameraPos.vx=0;
m_cameraScrollDir=0;
} }
else if(m_cameraPos.vx>m_mapCameraEdges.vx) else if(m_cameraPos.vx>m_mapCameraEdges.vx)
{ {
m_playerScreenGeomPos.vx-=m_mapCameraEdges.vx-m_cameraPos.vx; m_playerScreenGeomPos.vx-=m_mapCameraEdges.vx-m_cameraPos.vx;
m_cameraPos.vx=m_mapCameraEdges.vx; m_cameraPos.vx=m_mapCameraEdges.vx;
m_cameraScrollDir=0;
} }
if(m_cameraPos.vy<0) if(m_cameraPos.vy<0)
{ {
m_playerScreenGeomPos.vy+=m_cameraPos.vy; m_playerScreenGeomPos.vy+=m_cameraPos.vy;
m_cameraPos.vy=0; m_cameraPos.vy=0;
m_cameraScrollDir=0;
} }
else if(m_cameraPos.vy>m_mapCameraEdges.vy) else if(m_cameraPos.vy>m_mapCameraEdges.vy)
{ {
m_playerScreenGeomPos.vy-=m_mapCameraEdges.vy-m_cameraPos.vy; m_playerScreenGeomPos.vy-=m_mapCameraEdges.vy-m_cameraPos.vy;
m_cameraPos.vy=m_mapCameraEdges.vy; m_cameraPos.vy=m_mapCameraEdges.vy;
m_cameraScrollDir=0;
} }
CPlayerThing::think(_frames); CPlayerThing::think(_frames);

View File

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

View File

@ -21,6 +21,27 @@
#include "gfx\sprbank.h" #include "gfx\sprbank.h"
#endif #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 /* Std Lib
------- */ ------- */
@ -53,7 +74,25 @@
Vars Vars
---- */ ---- */
static PlayerMetrics s_playerMetrics= 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 DEFAULT_PLAYER_JUMP_VELOCITY/2, // PM__JUMP_VELOCITY
DEFAULT_PLAYER_MAX_JUMP_FRAMES/2, // PM__MAX_JUMP_FRAMES DEFAULT_PLAYER_MAX_JUMP_FRAMES/2, // PM__MAX_JUMP_FRAMES
@ -160,5 +199,16 @@ const struct PlayerMetrics *CPlayerModeCoralBlower::getPlayerMetrics()
return &s_playerMetrics; return &s_playerMetrics;
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CPlayerState **CPlayerModeCoralBlower::getStateTable()
{
return s_stateTable;
}
/*=========================================================================== /*===========================================================================
end */ end */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,10 @@
#include "player\pstates.h" #include "player\pstates.h"
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
#endif
/* Std Lib /* Std Lib
------- */ ------- */
@ -38,8 +42,22 @@ public:
void enter(class CPlayerModeBase *_playerMode); void enter(class CPlayerModeBase *_playerMode);
void think(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: 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 Globals
------- */ ------- */
extern CPlayerStateRun s_stateRun;
extern CPlayerStateWalk s_stateWalk;
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Functions Functions
--------- */ --------- */