diff --git a/source/player/modelist.cpp b/source/player/modelist.cpp deleted file mode 100644 index aab5ef5c2..000000000 --- a/source/player/modelist.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/*========================================================================= - - modelist.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\player.h" - - -#ifndef __PLAYER_PMODES_H__ -#include "player/pmodes.h" -#endif - -#ifndef __PLAYER_PMBALLOON_H__ -#include "player/pmballoon.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 __PLAYER__PSDEAD_H__ -#include "player\psdead.h" -#endif - -#ifndef __PLAYER__PSFLY_H__ -#include "player\psfly.h" -#endif - -#ifndef __PLAYER__PSBALLOON_H__ -#include "player\psballoon.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -CPlayerMode modeEmpty; -CPlayerModeBalloon modeBalloon; - -CPlayerStateUnarmedIdle stateUnarmedIdle; -CPlayerStateCoralBlowerIdle stateCoralBlowerIdle; -CPlayerStateTeeterIdle stateTeeterIdle; -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; -CPlayerStateDead stateDead; -CPlayerStateFly stateFly; -CPlayerStateBalloon stateBalloon; - - - - - - - - - -CPlayer::PlayerMode CPlayer::s_modes[NUM_PLAYERMODES]= -{ - // - // PLAYER_MODE_BASICUNARMED - // Basic player mode. No attack, only butt bounce - // - { - { { - DEFAULT_PLAYER_JUMP_VELOCITY, // PM__JUMP_VELOCITY - DEFAULT_PLAYER_MAX_JUMP_FRAMES, // PM__MAX_JUMP_FRAMES - DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN - } }, - &modeEmpty, - { - &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 - NULL, // STATE_ATTACK - NULL, // STATE_RUNATTACK - NULL, // STATE_AIRATTACK - &stateDuck, // STATE_DUCK - &stateSoackUp, // STATE_SOAKUP - &stateGetup, // STATE_GETUP - &stateDead, // STATE_DEAD - } - }, - - // - // PLAYER_MODE_FULLUNARMED - // Full unarmed player mode. With butt bounce and karate chop - // - { - { { - DEFAULT_PLAYER_JUMP_VELOCITY, // PM__JUMP_VELOCITY - DEFAULT_PLAYER_MAX_JUMP_FRAMES, // PM__MAX_JUMP_FRAMES - DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN - } }, - &modeEmpty, - { - &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 - &stateChop, // STATE_ATTACK - &stateRunChop, // STATE_RUNATTACK - &stateAirChop, // STATE_AIRATTACK - &stateDuck, // STATE_DUCK - &stateSoackUp, // STATE_SOAKUP - &stateGetup, // STATE_GETUP - &stateDead, // STATE_DEAD - } - }, - - // - // PLAYER_MODE_BALLOON - // Holding a balloon - // - { - { { - 0, // PM__JUMP_VELOCITY - 0, // PM__MAX_JUMP_FRAMES - 0, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY/2, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP/4, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN/5, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN/5, // PM__RUN_SLOWDOWN - } }, - &modeBalloon, - { - &stateBalloon, // STATE_IDLE - NULL, // STATE_IDLETEETER - NULL, // STATE_JUMP - NULL, // STATE_RUN - NULL, // STATE_FALL - NULL, // STATE_FALLFAR - NULL, // STATE_BUTTBOUNCE - NULL, // STATE_BUTTFALL - NULL, // STATE_BUTTLAND - NULL, // STATE_ATTACK - NULL, // STATE_RUNATTACK - NULL, // STATE_AIRATTACK - NULL, // STATE_DUCK - NULL, // STATE_SOAKUP - NULL, // STATE_GETUP - &stateDead, // STATE_DEAD - } - }, - - // - // PLAYER_MODE_NET - // Armed with net - // - { - { { - DEFAULT_PLAYER_JUMP_VELOCITY, // PM__JUMP_VELOCITY - DEFAULT_PLAYER_MAX_JUMP_FRAMES, // PM__MAX_JUMP_FRAMES - DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN - } }, - &modeEmpty, - { - &stateUnarmedIdle, // STATE_IDLE - &stateTeeterIdle, // STATE_IDLETEETER - &stateJump, // STATE_JUMP - &stateRun, // STATE_RUN - &stateFall, // STATE_FALL - &stateFallFar, // STATE_FALLFAR - NULL, // STATE_BUTTBOUNCE - NULL, // STATE_BUTTFALL - NULL, // STATE_BUTTLAND - NULL, // STATE_ATTACK - NULL, // STATE_RUNATTACK - NULL, // STATE_AIRATTACK - NULL, // STATE_DUCK - NULL, // STATE_SOAKUP - NULL, // STATE_GETUP - &stateDead, // STATE_DEAD - } - }, - - // - // PLAYER_MODE_CORALBLOWER - // Armed with coral blower ( Heavy weapon so slows SB down ) - // - { - { { - DEFAULT_PLAYER_JUMP_VELOCITY/3, // PM__JUMP_VELOCITY - DEFAULT_PLAYER_MAX_JUMP_FRAMES/2, // PM__MAX_JUMP_FRAMES - DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY/2, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP/2, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN - } }, - &modeEmpty, - { - &stateCoralBlowerIdle, // STATE_IDLE - &stateTeeterIdle, // STATE_IDLETEETER - &stateJump, // STATE_JUMP - &stateRun, // STATE_RUN - &stateFall, // STATE_FALL - &stateFallFar, // STATE_FALLFAR - NULL, // STATE_BUTTBOUNCE - NULL, // STATE_BUTTFALL - NULL, // STATE_BUTTLAND - NULL, // STATE_ATTACK - NULL, // STATE_RUNATTACK - NULL, // STATE_AIRATTACK - NULL, // STATE_DUCK - NULL, // STATE_SOAKUP - NULL, // STATE_GETUP - &stateDead, // STATE_DEAD - } - }, - - // - // PLAYER_MODE_FLY - // Fly mode ( A useful debugging mode.. ) - // - { - { { - DEFAULT_PLAYER_JUMP_VELOCITY, // PM__JUMP_VELOCITY - DEFAULT_PLAYER_MAX_JUMP_FRAMES, // PM__MAX_JUMP_FRAMES - DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES - DEFAULT_PLAYER_MAX_RUN_VELOCITY, // PM__MAX_RUN_VELOCITY - DEFAULT_PLAYER_RUN_SPEEDUP, // PM__RUN_SPEEDUP - DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN - DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN - } }, - &modeEmpty, - { - &stateFly, // STATE_IDLE - &stateFly, // STATE_IDLETEETER - &stateFly, // STATE_JUMP - &stateFly, // STATE_RUN - &stateFly, // STATE_FALL - &stateFly, // STATE_FALLFAR - &stateFly, // STATE_BUTTBOUNCE - &stateFly, // STATE_BUTTFALL - &stateFly, // STATE_BUTTLAND - &stateFly, // STATE_ATTACK - &stateFly, // STATE_RUNATTACK - &stateFly, // STATE_AIRATTACK - &stateFly, // STATE_DUCK - &stateFly, // STATE_SOAKUP - &stateFly, // STATE_GETUP - &stateFly, // STATE_DEAD - } - }, -}; - - -/*=========================================================================== -end */ diff --git a/source/player/pmballoon.h b/source/player/pmballoon.h deleted file mode 100644 index 8828331ff..000000000 --- a/source/player/pmballoon.h +++ /dev/null @@ -1,64 +0,0 @@ -/*========================================================================= - - pmballoon.h - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - -#ifndef __PLAYER_PMBALLOON_H__ -#define __PLAYER_PMBALLOON_H__ - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#ifndef __PLAYER_PMODES_H__ -#include "player/pmodes.h" -#endif - - -/* Std Lib - ------- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -class CPlayerModeBalloon: public CPlayerMode -{ -public: - virtual void enter(class CPlayer *_player); - virtual void think(class CPlayer *_player); - -private: - int m_timer; -}; - - -/*---------------------------------------------------------------------- - Globals - ------- */ - -/*---------------------------------------------------------------------- - Functions - --------- */ - -/*---------------------------------------------------------------------- */ - -#endif /* __PLAYER_PMBALLOON_H__ */ - -/*=========================================================================== - end */ - - - diff --git a/source/player/pmballoon.cpp b/source/player/pmfly.cpp similarity index 76% rename from source/player/pmballoon.cpp rename to source/player/pmfly.cpp index 1563c9095..403ad358f 100644 --- a/source/player/pmballoon.cpp +++ b/source/player/pmfly.cpp @@ -1,6 +1,6 @@ /*========================================================================= - pmballoon.cpp + pmfly.cpp Author: PKG Created: @@ -15,10 +15,10 @@ Includes -------- */ -#include "player/pmballoon.h" +#include "player\pmfly.h" #ifndef __PLAYER_PLAYER_H__ -#include "player/player.h" +#include "player\player.h" #endif @@ -50,10 +50,8 @@ Params: Returns: ---------------------------------------------------------------------- */ -int balloontime=60*20; -void CPlayerModeBalloon::enter(class CPlayer *_player) +void CPlayerModeFly::enter() { - m_timer=balloontime; } /*---------------------------------------------------------------------- @@ -62,12 +60,30 @@ void CPlayerModeBalloon::enter(class CPlayer *_player) Params: Returns: ---------------------------------------------------------------------- */ -void CPlayerModeBalloon::think(class CPlayer *_player) +void CPlayerModeFly::think() { - if(--m_timer==0) + DVECTOR pos; + int controlHeld; + + pos=getPlayerPos(); + controlHeld=getPadInputHeld(); + if(controlHeld&PI_LEFT) { - _player->setMode(PLAYER_MODE_FULLUNARMED); + pos.vx-=5; } + else if(controlHeld&PI_RIGHT) + { + pos.vx+=5; + } + if(controlHeld&PI_UP) + { + pos.vy-=5; + } + else if(controlHeld&PI_DOWN) + { + pos.vy+=5; + } + setPlayerPos(&pos); } /*=========================================================================== diff --git a/source/player/psfly.h b/source/player/pmfly.h similarity index 79% rename from source/player/psfly.h rename to source/player/pmfly.h index 45e095643..b6770cb1a 100644 --- a/source/player/psfly.h +++ b/source/player/pmfly.h @@ -1,6 +1,6 @@ /*========================================================================= - psfly.h + pmfly.h Author: PKG Created: @@ -11,14 +11,16 @@ ===========================================================================*/ -#ifndef __PLAYER_PSFLY_H__ -#define __PLAYER_PSFLY_H__ +#ifndef __PLAYER_PMFLY_H__ +#define __PLAYER_PMFLY_H__ /*---------------------------------------------------------------------- Includes -------- */ -#include "player\pstates.h" +#ifndef __PLAYER_PMODES_H__ +#include "player\pmodes.h" +#endif /* Std Lib @@ -32,11 +34,11 @@ Structure defintions -------------------- */ -class CPlayerStateFly : public CPlayerState +class CPlayerModeFly : public CPlayerModeBasic { public: - virtual void enter(class CPlayer *_player); - virtual void think(class CPlayer *_player); + virtual void enter(); + virtual void think(); }; @@ -51,7 +53,7 @@ public: /*---------------------------------------------------------------------- */ -#endif /* __PLAYER_PSFLY_H__ */ +#endif /* __PLAYER_PMFLY_H__ */ /*=========================================================================== end */ diff --git a/source/player/pmodes.cpp b/source/player/pmodes.cpp new file mode 100644 index 000000000..ccbbe9ef0 --- /dev/null +++ b/source/player/pmodes.cpp @@ -0,0 +1,657 @@ +/*========================================================================= + + pmodes.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "player\pmodes.h" + +#ifndef __PLAYER_PLAYER_H__ +#include "player\player.h" +#endif + +#ifndef __PLAYER_PSTATES_H__ +#include "player\pstates.h" +#endif + +#ifndef __LAYER_COLLISION_H__ +#include "level\layercollision.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__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 __PLAYER__PSDEAD_H__ +#include "player\psdead.h" +#endif + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +#ifndef __ANIM_SPONGEBOB_HEADER__ +#include +#endif + + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + 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; + +/* +static CPlayerStateDead stateDead; +*/ + +CPlayerState *CPlayerModeBasic::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 +}; + +PlayerMetrics CPlayerModeBasic::s_playerMetrics= +{ { + DEFAULT_PLAYER_JUMP_VELOCITY, // PM__JUMP_VELOCITY + DEFAULT_PLAYER_MAX_JUMP_FRAMES, // PM__MAX_JUMP_FRAMES + DEFAULT_PLAYER_MAX_SAFE_FALL_FRAMES, // PM__MAX_SAFE_FALL_FRAMES + DEFAULT_PLAYER_MAX_RUN_VELOCITY, // PM__MAX_RUN_VELOCITY + DEFAULT_PLAYER_RUN_SPEEDUP, // PM__RUN_SPEEDUP + DEFAULT_PLAYER_RUN_REVERSESLOWDOWN, // PM__RUN_REVERSESLOWDOWN + DEFAULT_PLAYER_RUN_SLOWDOWN, // PM__RUN_SLOWDOWN +} }; + + + + + + + + + + + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerMode::getPadInputHeld() {return m_player->getPadInputHeld();} +int CPlayerMode::getPadInputDown() {return m_player->getPadInputDown();} +DVECTOR CPlayerMode::getPlayerPos() {return m_player->getPlayerPos();} +void CPlayerMode::setPlayerPos(DVECTOR *_pos) {m_player->setPlayerPos(_pos);} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::enter() +{ + m_fallFrames=0; + setState(STATE_IDLE); + m_moveVelocity.vx=m_moveVelocity.vy=0; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::think() +{ + s_stateTable[m_currentState]->think(this); + thinkVerticalMovement(); + thinkHorizontalMovement(); + + // Teeter if on an edge + if(canTeeter()&&isOnEdge()) + { + setState(STATE_IDLETEETER); + } + +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::render() +{ +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::thinkVerticalMovement() +{ + CLayerCollision *collision; + DVECTOR pos; + int colHeight; + + collision=m_player->getLayerCollision(); + pos=m_player->getPlayerPos(); + + colHeight=collision->getHeightFromGround(pos.vx,pos.vy,1); + +//New collision stuff (pkg) +//if(m_layerCollision->getCollisionType(Pos.vx,Pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT))&COLLISION_TYPE_MASK) +//{ +// m_moveVelocity.vy=0; +// return; +//} + if(colHeight>=0) + { + // Above or on the ground + // Are we falling? + if(m_moveVelocity.vy>0) + { + // Yes.. Check to see if we're about to hit/go through the ground + colHeight=collision->getHeightFromGround(pos.vx,pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT),PLAYER_TERMINAL_VELOCITY+1); + + if(colHeight<=0) + { + // Just hit the ground + // Stick at ground level + pos.vy+=(m_moveVelocity.vy>>VELOCITY_SHIFT)+colHeight; + m_moveVelocity.vy=0; + m_fallFrames=0; + if(m_currentState==STATE_BUTTFALL) + { + // Landed from a butt bounce + setState(STATE_BUTTLAND); + } + else if(m_currentState==STATE_FALLFAR) + { + // Landed from a painfully long fall + setState(STATE_IDLE); + m_player->takeDamage(DAMAGE__FALL); + m_moveVelocity.vx=0; + CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_LAND_AFTER_FALL); + } + else if(m_moveVelocity.vx) + { + // Landed from a jump with x movement + setState(STATE_RUN); + } + else + { + // Landed from a jump with no x movement + setState(STATE_IDLE); + setAnimNo(ANIM_SPONGEBOB_JUMPEND); + } + } + } + else if(colHeight) + { + if(m_currentState!=STATE_FALL&&m_currentState!=STATE_FALLFAR&& + m_currentState!=STATE_BUTTFALL&&m_currentState!=STATE_BUTTBOUNCE&& + m_currentState!=STATE_JUMP) + { + // Was floating in the air.. fall! + +// if ( !m_onPlatform ) +// { + setState(STATE_FALL); +// } + } + } + } + else + { +/* + // Below ground + // Perhaps we should be falling? + if(m_currentState!=STATE_FALL&&m_currentState!=STATE_FALLFAR&& + m_currentState!=STATE_BUTTFALL&&m_currentState!=STATE_BUTTBOUNCE&& + m_currentState!=STATE_JUMP) + { + setState(STATE_FALL); + } +*/ + } + + pos.vy+=m_moveVelocity.vy>>VELOCITY_SHIFT; + m_player->setPlayerPos(&pos); +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::thinkHorizontalMovement() +{ + if(m_moveVelocity.vx) + { + CLayerCollision *collision; + DVECTOR pos; + + collision=m_player->getLayerCollision(); + pos=m_player->getPlayerPos(); +//New collision stuff (pkg) +//if(m_layerCollision->getCollisionType(Pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),Pos.vy)&COLLISION_TYPE_MASK) +//{ +// m_moveVelocity.vx=0; +// return; +//} + int colHeight; + colHeight=collision->getHeightFromGround(pos.vx,pos.vy,5); + if(colHeight==0) + { + // Ok.. we're on the ground. What happens if we move left/right + colHeight=collision->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy); + if(colHeight<-8) + { + // Big step up. Stop at the edge of the obstruction + int dir,vx,cx,i; + if(m_moveVelocity.vx<0) + { + dir=-1; + vx=-m_moveVelocity.vx>>VELOCITY_SHIFT; + } + else + { + dir=+1; + vx=m_moveVelocity.vx>>VELOCITY_SHIFT; + } + cx=pos.vx; + for(i=0;igetHeightFromGround(cx,pos.vy)<-8) + { + break; + } + cx+=dir; + } + pos.vx=cx-dir; + + // If running then go to idle, otherwise leave in same state + if(m_currentState==STATE_RUN) + { + setState(STATE_IDLE); + } + m_moveVelocity.vx=0; + + // Get the height at this new position and then try the step-up code below. + // Without this, there are problems when you run up a slope and hit a wall at the same time + colHeight=collision->getHeightFromGround(pos.vx,pos.vy); + } + if(colHeight&&colHeight>=-8&&colHeight<=8) + { + // Small step up/down. Follow the contour of the level + pos.vy+=colHeight; + } + } + else + { + // In the air +// if(!(colHeight<0&&m_currentState==STATE_JUMP)) // Lets you jump through platforms from below + if(colHeight>=0) // Lets you jump through platforms from below + { + colHeight=collision->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy,5); + if(colHeight<0) + { + // Stop at the edge of the obstruction + int dir,vx,cx,i; + if(m_moveVelocity.vx<0) + { + dir=-1; + vx=-m_moveVelocity.vx>>VELOCITY_SHIFT; + } + else + { + dir=+1; + vx=m_moveVelocity.vx>>VELOCITY_SHIFT; + } + cx=pos.vx; + for(i=0;igetHeightFromGround(cx,pos.vy)<0) + { + break; + } + cx+=dir; + } + pos.vx=cx-dir; + m_moveVelocity.vx=0; + } + } + } + pos.vx+=m_moveVelocity.vx>>VELOCITY_SHIFT; + m_player->setPlayerPos(&pos); + } +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +const struct PlayerMetrics *CPlayerModeBasic::getPlayerMetrics() +{ + return &s_playerMetrics; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeBasic::setState(int _state) +{ + CPlayerState *nextState; + int ret=false; + + nextState=s_stateTable[_state]; + if(nextState) + { + m_currentStateClass=nextState; + m_currentStateClass->enter(this); + m_currentState=(PLAYER_STATE)_state; + ret=true; + } + return ret; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeBasic::getFacing() {return m_player->getFacing();} +void CPlayerModeBasic::setFacing(int _facing) {m_player->setFacing(_facing);} +void CPlayerModeBasic::setAnimNo(int _animNo) {m_player->setAnimNo(_animNo);} +void CPlayerModeBasic::setAnimFrame(int _animFrame) {m_player->setAnimFrame(_animFrame);} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeBasic::advanceAnimFrameAndCheckForEndOfAnim() +{ + int animFrame,frameCount; + int looped; + animFrame=m_player->getAnimFrame()+1; + frameCount=m_player->getAnimFrameCount(); + looped=false; + if(animFrame>=frameCount) + { + looped=true; + animFrame=0; + } + m_player->setAnimFrame(animFrame); + return looped; + +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +DVECTOR CPlayerModeBasic::getMoveVelocity() {return m_moveVelocity;} +void CPlayerModeBasic::zeroMoveVelocity() {m_moveVelocity.vx=m_moveVelocity.vy=0;} +void CPlayerModeBasic::setMoveVelocity(DVECTOR *_moveVel) {m_moveVelocity=*_moveVel;} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: FACING_LEFT if left half of player is hanging, FACING_RIGHT + if right half of player is hanging or 0 if no part of the + player is hanging + ---------------------------------------------------------------------- */ +int csize=5; +int cheight=15; +int CPlayerModeBasic::isOnEdge() +{ + CLayerCollision *collision; + DVECTOR pos; + int ret; + + collision=m_player->getLayerCollision(); + pos=m_player->getPlayerPos(); + ret=0; + if(collision->getHeightFromGround(pos.vx-csize,pos.vy,cheight+1)>cheight) + { + ret=FACING_LEFT; + } + else if(collision->getHeightFromGround(pos.vx+csize,pos.vy,cheight+1)>cheight) + { + ret=FACING_RIGHT; + } + return ret; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeBasic::canMoveLeft() +{ + DVECTOR pos; + pos=m_player->getPlayerPos(); + return m_player->getLayerCollision()->getHeightFromGround(pos.vx-1,pos.vy,16)>-8?true:false; +} + +int CPlayerModeBasic::canMoveRight() +{ + DVECTOR pos; + pos=m_player->getPlayerPos(); + return m_player->getLayerCollision()->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeBasic::moveLeft() +{ + const PlayerMetrics *metrics; + metrics=getPlayerMetrics(); + + setFacing(FACING_LEFT); + if(m_moveVelocity.vx<=0) + { + m_moveVelocity.vx-=metrics->m_metric[PM__RUN_SPEEDUP]; + if(m_moveVelocity.vx<-metrics->m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<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 CPlayerModeBasic::moveRight() +{ + const PlayerMetrics *metrics; + metrics=getPlayerMetrics(); + + setFacing(FACING_RIGHT); + if(m_moveVelocity.vx>=0) + { + m_moveVelocity.vx+=metrics->m_metric[PM__RUN_SPEEDUP]; + if(m_moveVelocity.vx>metrics->m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__RUN_REVERSESLOWDOWN]; + } + + /* + if(m_moveVelocity.vx>CAMERA_STARTMOVETHRESHOLD||m_cameraScrollPos.vx>CAMERA_SCROLLTHRESHOLD<<8) + { + m_cameraScrollDir=-1; + } + else if(m_moveVelocity.vxm_metric[PM__RUN_SLOWDOWN]; + if(m_moveVelocity.vx>=0) + { + m_moveVelocity.vx=0; + ret=true; + } + } + else if(m_moveVelocity.vx>0) + { + m_moveVelocity.vx-=metrics->m_metric[PM__RUN_SLOWDOWN]; + if(m_moveVelocity.vx<=0) + { + m_moveVelocity.vx=0; + ret=true; + } + } + return ret; +} +void CPlayerModeBasic::jump() +{ + const PlayerMetrics *metrics; + metrics=getPlayerMetrics(); + m_moveVelocity.vy=-metrics->m_metric[PM__JUMP_VELOCITY]<=PLAYER_TERMINAL_VELOCITY<metrics->m_metric[PM__MAX_SAFE_FALL_FRAMES]) + { + setState(STATE_FALLFAR); + } + } + } +} + + + +/*=========================================================================== +end */ diff --git a/source/player/psballoon.cpp b/source/player/psballoon.cpp deleted file mode 100644 index 1b0dacca5..000000000 --- a/source/player/psballoon.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/*========================================================================= - - psballoon.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\psballoon.h" - -#ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -#ifndef __ANIM_SPONGEBOB_HEADER__ -#include -#endif - - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -#define MAX_BALLOON_VELOCITY 5 - - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateBalloon::enter(CPlayer *_player) -{ - setAnimNo(_player,ANIM_SPONGEBOB_HOVER); - m_canDropBalloon=false; -} - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: ----------------------------------------------------------------------- */ -void CPlayerStateBalloon::think(CPlayer *_player) -{ - int controlDown,controlHeld; - controlDown=getPadInputDown(_player); - controlHeld=getPadInputHeld(_player); - - if(m_canDropBalloon&&controlDown&PI_ACTION) - { - setMode(_player,PLAYER_MODE_FULLUNARMED); - } - - if(controlHeld&PI_LEFT) - { - moveLeft(_player); - } - else if(controlHeld&PI_RIGHT) - { - moveRight(_player); - } - else - { - slowdown(_player); - } - - DVECTOR moveVel=getMoveVelocity(_player); - if(moveVel.vy>-MAX_BALLOON_VELOCITY) - { - moveVel.vy--; - } - if(moveVel.vy<-MAX_BALLOON_VELOCITY) - { - moveVel.vy++; - } - setMoveVelocity(_player,&moveVel); - - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) - { - m_canDropBalloon=true; - } -} - -/*=========================================================================== - end */ diff --git a/source/player/psballoon.h b/source/player/psballoon.h deleted file mode 100644 index 436b85061..000000000 --- a/source/player/psballoon.h +++ /dev/null @@ -1,62 +0,0 @@ -/*========================================================================= - - psballoon.h - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - -#ifndef __PLAYER_PSBALLOON_H__ -#define __PLAYER_PSBALLOON_H__ - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\pstates.h" - - -/* Std Lib - ------- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -class CPlayerStateBalloon : public CPlayerState -{ -public: - void enter(class CPlayer *_player); - void think(class CPlayer *_player); - -private: - int m_canDropBalloon; -}; - - -/*---------------------------------------------------------------------- - Globals - ------- */ - -/*---------------------------------------------------------------------- - Functions - --------- */ - -/*---------------------------------------------------------------------- */ - -#endif /* __PLAYER_PSBALLOON_H__ */ - -/*=========================================================================== - end */ - - - diff --git a/source/player/pschop.cpp b/source/player/pschop.cpp deleted file mode 100644 index e75323acc..000000000 --- a/source/player/pschop.cpp +++ /dev/null @@ -1,151 +0,0 @@ - -/*========================================================================= - - pschop.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\pschop.h" - -#ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -#ifndef __ANIM_SPONGEBOB_HEADER__ -#include -#endif - - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateChop::enter(CPlayer *_player) -{ - setAnimNo(_player,ANIM_SPONGEBOB_KARATE); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateChop::think(CPlayer *_player) -{ - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) - { - setState(_player,STATE_IDLE); - } -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateRunChop::think(CPlayer *_player) -{ - int controlHeld; - controlHeld=getPadInputHeld(_player); - - if(controlHeld&PI_LEFT) - { - moveLeft(_player); - } - else if(controlHeld&PI_RIGHT) - { - moveRight(_player); - } - else - { - slowdown(_player); - } - - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) - { - if(getMoveVelocity(_player).vx==0) - { - setState(_player,STATE_IDLE); - } - else - { - setState(_player,STATE_RUN); - } - } -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateAirChop::think(CPlayer *_player) -{ - int controlHeld; - controlHeld=getPadInputHeld(_player); - - if(controlHeld&PI_LEFT) - { - moveLeft(_player); - } - else if(controlHeld&PI_RIGHT) - { - moveRight(_player); - } - else - { - slowdown(_player); - } - - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) - { - setState(_player,STATE_FALL); - } -} - - -/*=========================================================================== - end */ diff --git a/source/player/pschop.h b/source/player/pschop.h deleted file mode 100644 index aa572c195..000000000 --- a/source/player/pschop.h +++ /dev/null @@ -1,76 +0,0 @@ -/*========================================================================= - - pschop.h - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - -#ifndef __PLAYER_PSCHOP_H__ -#define __PLAYER_PSCHOP_H__ - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\pstates.h" - - -/* Std Lib - ------- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -class CPlayerStateChop : public CPlayerState -{ -public: - void enter(class CPlayer *_player); - void think(class CPlayer *_player); - -}; - - -class CPlayerStateRunChop : public CPlayerStateChop -{ -public: - void think(class CPlayer *_player); - -}; - - -class CPlayerStateAirChop : public CPlayerStateChop -{ -public: - void think(class CPlayer *_player); - -}; - - -/*---------------------------------------------------------------------- - Globals - ------- */ - -/*---------------------------------------------------------------------- - Functions - --------- */ - -/*---------------------------------------------------------------------- */ - -#endif /* __PLAYER_PSCHOP_H__ */ - -/*=========================================================================== - end */ - - - diff --git a/source/player/psdead.cpp b/source/player/psdead.cpp deleted file mode 100644 index f2fa6a2ca..000000000 --- a/source/player/psdead.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*========================================================================= - - psdead.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\psdead.h" - -#ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" -#endif - -#ifndef __SYSTEM_GSTATE_H__ -#include "system\gstate.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -#ifndef __ANIM_SPONGEBOB_HEADER__ -#include -#endif - - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateDead::enter(CPlayer *_player) -{ - setAnimNo(_player,ANIM_SPONGEBOB_DEATHSPIN); - - m_deadCounter=0; -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateDead::think(CPlayer *_player) -{ - if(!m_deadCounter) - { - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) - { - retreatAnimFrameAndCheckForEndOfAnim(_player); - m_deadCounter=1; - } - } - else - { - if(++m_deadCounter>10*GameState::getOneSecondInFrames()|| - getPadInputDown(_player)&PI_ACTION) - { - respawn(_player); - } - } -} - - -/*=========================================================================== - end */ diff --git a/source/player/psdead.h b/source/player/psdead.h deleted file mode 100644 index 1280f74a6..000000000 --- a/source/player/psdead.h +++ /dev/null @@ -1,63 +0,0 @@ -/*========================================================================= - - psdead.h - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - -#ifndef __PLAYER_PSDEAD_H__ -#define __PLAYER_PSDEAD_H__ - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\pstates.h" - - -/* Std Lib - ------- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -class CPlayerStateDead : public CPlayerState -{ -public: - virtual void enter(class CPlayer *_player); - virtual void think(class CPlayer *_player); - - -private: - int m_deadCounter; -}; - - -/*---------------------------------------------------------------------- - Globals - ------- */ - -/*---------------------------------------------------------------------- - Functions - --------- */ - -/*---------------------------------------------------------------------- */ - -#endif /* __PLAYER_PSDEAD_H__ */ - -/*=========================================================================== - end */ - - - diff --git a/source/player/psfly.cpp b/source/player/psfly.cpp deleted file mode 100644 index dd8de06d3..000000000 --- a/source/player/psfly.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*========================================================================= - - psfly.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: Debugginf mode to allow SB to fly around the map - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\psfly.h" - -#ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -#ifndef __ANIM_SPONGEBOB_HEADER__ -#include -#endif - - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateFly::enter(CPlayer *_player) -{ - DVECTOR move; - - move.vx=0; - move.vy=0; - setMoveVelocity(_player,&move); - setAnimNo(_player,ANIM_SPONGEBOB_IDLEHOOLA); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerStateFly::think(CPlayer *_player) -{ - int controlHeld; - DVECTOR pos; - - controlHeld=getPadInputHeld(_player); - pos=getPlayerPos(_player); - if(controlHeld&PI_LEFT) - { - pos.vx-=8; - } - else if(controlHeld&PI_RIGHT) - { - pos.vx+=8; - } - if(controlHeld&PI_UP) - { - pos.vy-=8; - } - else if(controlHeld&PI_DOWN) - { - pos.vy+=8; - } - this->setPlayerPos(_player,&pos); - - advanceAnimFrameAndCheckForEndOfAnim(_player); -} - - -/*=========================================================================== - end */ diff --git a/source/player/pstates.cpp b/source/player/pstates.cpp deleted file mode 100644 index 52fd8d658..000000000 --- a/source/player/pstates.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/*========================================================================= - - pstates.cpp - - Author: PKG - Created: - Project: Spongebob - Purpose: - - Copyright (c) 2001 Climax Development Ltd - -===========================================================================*/ - - -/*---------------------------------------------------------------------- - Includes - -------- */ - -#include "player\pstates.h" - -#ifndef __PLAYER_PLAYER_H__ -#include "player\player.h" -#endif - - -/* Std Lib - ------- */ - -/* Data - ---- */ - -/*---------------------------------------------------------------------- - Tyepdefs && Defines - ------------------- */ - -/*---------------------------------------------------------------------- - Structure defintions - -------------------- */ - -/*---------------------------------------------------------------------- - Function Prototypes - ------------------- */ - -/*---------------------------------------------------------------------- - Vars - ---- */ - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -const PlayerMetrics *CPlayerState::getPlayerMetrics(CPlayer *_player) -{ - return _player->getPlayerMetrics(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::setState(CPlayer *_player,int _state) -{ - return _player->setState((PLAYER_STATE)_state); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setMode(class CPlayer *_player,int _mode) -{ - _player->setMode((PLAYER_MODE)_mode); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::getFacing(CPlayer *_player) -{ - return _player->getFacing(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setFacing(CPlayer *_player,int _facing) -{ - _player->setFacing(_facing); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::getAnimNo(CPlayer *_player) -{ - return _player->getAnimNo(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setAnimNo(CPlayer *_player,int _animNo) -{ - _player->setAnimNo(_animNo); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setAnimFrame(CPlayer *_player,int _animFrame) -{ - _player->setAnimFrame(_animFrame); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::advanceAnimFrameAndCheckForEndOfAnim(class CPlayer *_player) -{ - int animFrame,frameCount; - int looped; - animFrame=_player->getAnimFrame()+1; - frameCount=_player->getAnimFrameCount(); - looped=false; - if(animFrame>=frameCount) - { - looped=true; - animFrame=0; - } - _player->setAnimFrame(animFrame); - return looped; -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::retreatAnimFrameAndCheckForEndOfAnim(class CPlayer *_player) -{ - int animFrame; - int looped; - animFrame=_player->getAnimFrame()-1; - looped=false; - if(animFrame<0) - { - looped=true; - animFrame=_player->getAnimFrameCount()-1; - } - _player->setAnimFrame(animFrame); - return looped; -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -DVECTOR CPlayerState::getMoveVelocity(CPlayer *_player) -{ - return _player->getMoveVelocity(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setMoveVelocity(CPlayer *_player,DVECTOR *_moveVel) -{ - _player->setMoveVelocity(_moveVel); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -DVECTOR CPlayerState::getPlayerPos(CPlayer *_player) -{ - return _player->getPlayerPos(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::setPlayerPos(class CPlayer *_player,DVECTOR *_pos) -{ - return _player->setPlayerPos(_pos); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::getPadInputHeld(CPlayer *_player) -{ - return _player->getPadInputHeld(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::getPadInputDown(CPlayer *_player) -{ - return _player->getPadInputDown(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::isOnEdge(class CPlayer *_player) -{ - return _player->isOnEdge(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerState::canMoveLeft(class CPlayer *_player) -{ - return _player->canMoveLeft(); -} -int CPlayerState::canMoveRight(class CPlayer *_player) -{ - return _player->canMoveRight(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::moveLeft(CPlayer *_player) -{ - _player->moveLeft(); -} -void CPlayerState::moveRight(CPlayer *_player) -{ - _player->moveRight(); -} -void CPlayerState::slowdown(CPlayer *_player) -{ - _player->slowdown(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::jump(CPlayer *_player) -{ - _player->jump(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::fall(CPlayer *_player) -{ - _player->fall(); -} - - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CPlayerState::respawn(CPlayer *_player) -{ - _player->respawn(); -} - - -/*=========================================================================== - end */