diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 0eec0ab01..4e181df45 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -108,7 +108,7 @@ // The collision box is this high.. if SB keeps falling through platforms then it *should* be sufficient // just to up this a bit -#define PLATFORMCOLLISIONHEIGHT 60 +#define PLATFORMCOLLISIONHEIGHT 80 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/player/player.cpp b/source/player/player.cpp index fe73550ed..d52a71e34 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -800,6 +800,7 @@ static int lastposnum=0; #ifdef __USER_paul__ int mouth=-1,eyes=-1; #endif + void CPlayer::render() { CPlayerThing::render(); @@ -926,11 +927,11 @@ void CPlayer::setMapSize(DVECTOR _mapSize) int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight) { int height; - CThing *platform; - height=height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight); - if(height<_maxHeight) + height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight); + if(height>=_maxHeight) { + CThing *platform; platform=isOnPlatform(); if(platform) { @@ -1175,6 +1176,7 @@ void CPlayer::respawn() m_bubbleAmmo=0; m_jellyAmmo=0; + m_moveVelocity.vx=m_moveVelocity.vy=0; clearPlatform(); } diff --git a/source/player/player.h b/source/player/player.h index 349ce3d85..bc3560439 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -183,6 +183,8 @@ public: int isRecoveringFromHit() {return m_invincibleFrameCount!=0||m_currentMode==PLAYER_MODE_DEAD;} void registerAddon(PLAYER_ADDONS _addon); + DVECTOR *getMoveVelocity() {return &m_moveVelocity;} + void setMoveVelocity(const DVECTOR *_moveVelocity) {m_moveVelocity=*_moveVelocity;} public: void setMode(PLAYER_MODE _mode); @@ -196,6 +198,10 @@ public: private: void playAnimFrameSfx(int _animNo,int _animFrame); + DVECTOR m_moveVelocity; + + + public: DVECTOR getPlayerPos() {return Pos;} void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;} diff --git a/source/player/pmfly.cpp b/source/player/pmfly.cpp index 403ad358f..ffc678f35 100644 --- a/source/player/pmfly.cpp +++ b/source/player/pmfly.cpp @@ -60,6 +60,11 @@ void CPlayerModeFly::enter() Params: Returns: ---------------------------------------------------------------------- */ +#ifdef __USER_paul__ +int playerflyspeed=5; +#else +static const int playerflyspeed=5; +#endif void CPlayerModeFly::think() { DVECTOR pos; @@ -69,19 +74,19 @@ void CPlayerModeFly::think() controlHeld=getPadInputHeld(); if(controlHeld&PI_LEFT) { - pos.vx-=5; + pos.vx-=playerflyspeed; } else if(controlHeld&PI_RIGHT) { - pos.vx+=5; + pos.vx+=playerflyspeed; } if(controlHeld&PI_UP) { - pos.vy-=5; + pos.vy-=playerflyspeed; } else if(controlHeld&PI_DOWN) { - pos.vy+=5; + pos.vy+=playerflyspeed; } setPlayerPos(&pos); } diff --git a/source/player/pmodes.cpp b/source/player/pmodes.cpp index d1ab7e533..135162df4 100644 --- a/source/player/pmodes.cpp +++ b/source/player/pmodes.cpp @@ -154,7 +154,7 @@ void CPlayerModeBase::enter() { m_fallFrames=0; setState(STATE_IDLE); - m_moveVelocity.vx=m_moveVelocity.vy=0; + zeroMoveVelocity(); } /*---------------------------------------------------------------------- @@ -252,7 +252,7 @@ ATTACK_STATE CPlayerModeBase::getAttackState() ---------------------------------------------------------------------- */ void CPlayerModeBase::thinkVerticalMovement() { - if(m_player->moveVertical(m_moveVelocity.vy>>VELOCITY_SHIFT)) + if(m_player->moveVertical(m_player->getMoveVelocity()->vy>>VELOCITY_SHIFT)) { playerHasHitGround(); } @@ -278,14 +278,18 @@ void CPlayerModeBase::thinkVerticalMovement() ---------------------------------------------------------------------- */ void CPlayerModeBase::thinkHorizontalMovement() { - if(m_player->moveHorizontal(m_moveVelocity.vx>>VELOCITY_SHIFT)) + DVECTOR moveVel; + + moveVel=*m_player->getMoveVelocity(); + if(m_player->moveHorizontal(moveVel.vx>>VELOCITY_SHIFT)) { // If running then go to idle, otherwise leave in same state if(m_currentState==STATE_RUN) { setState(STATE_IDLE); } - m_moveVelocity.vx=0; + moveVel.vx=0; + setMoveVelocity(&moveVel); } } @@ -297,8 +301,10 @@ void CPlayerModeBase::thinkHorizontalMovement() ---------------------------------------------------------------------- */ void CPlayerModeBase::playerHasHitGround() { - // Grrr! - m_moveVelocity.vy=0; + DVECTOR moveVel; + + moveVel=*m_player->getMoveVelocity(); + moveVel.vy=0; m_fallFrames=0; if(m_currentState==STATE_BUTTFALL) { @@ -310,9 +316,9 @@ void CPlayerModeBase::playerHasHitGround() // Landed from a painfully long fall setState(STATE_HITGROUND); m_player->takeDamage(DAMAGE__FALL); - m_moveVelocity.vx=0; + moveVel.vx=0; } - else if(m_moveVelocity.vx) + else if(moveVel.vx) { // Landed from a jump with x movement setState(STATE_RUN); @@ -323,6 +329,7 @@ void CPlayerModeBase::playerHasHitGround() setState(STATE_IDLE); setAnimNo(ANIM_SPONGEBOB_JUMPEND); } + setMoveVelocity(&moveVel); } /*---------------------------------------------------------------------- @@ -402,9 +409,9 @@ int CPlayerModeBase::advanceAnimFrameAndCheckForEndOfAnim() Params: Returns: ---------------------------------------------------------------------- */ -DVECTOR CPlayerModeBase::getMoveVelocity() {return m_moveVelocity;} -void CPlayerModeBase::zeroMoveVelocity() {m_moveVelocity.vx=m_moveVelocity.vy=0;} -void CPlayerModeBase::setMoveVelocity(DVECTOR *_moveVel) {m_moveVelocity=*_moveVel;} +DVECTOR CPlayerModeBase::getMoveVelocity() {return *m_player->getMoveVelocity();} +void CPlayerModeBase::zeroMoveVelocity() {DVECTOR v={0,0};setMoveVelocity(&v);} +void CPlayerModeBase::setMoveVelocity(DVECTOR *_moveVel) {m_player->setMoveVelocity(_moveVel);} /*---------------------------------------------------------------------- Function: @@ -476,63 +483,72 @@ void CPlayerModeBase::setPlayerCollisionSize(int _x,int _y,int _w,int _h) void CPlayerModeBase::moveLeft() { const PlayerMetrics *metrics; - metrics=getPlayerMetrics(); + DVECTOR moveVel; + metrics=getPlayerMetrics(); + moveVel=*m_player->getMoveVelocity(); setFacing(FACING_LEFT); - if(m_moveVelocity.vx<=0) + if(moveVel.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__RUN_SPEEDUP]; + if(moveVel.vx<-metrics->m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__RUN_REVERSESLOWDOWN]; + moveVel.vx-=metrics->m_metric[PM__RUN_REVERSESLOWDOWN]; } + setMoveVelocity(&moveVel); } void CPlayerModeBase::moveRight() { const PlayerMetrics *metrics; + DVECTOR moveVel; + metrics=getPlayerMetrics(); - + moveVel=*m_player->getMoveVelocity(); setFacing(FACING_RIGHT); - if(m_moveVelocity.vx>=0) + if(moveVel.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__RUN_SPEEDUP]; + if(moveVel.vx>metrics->m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__MAX_RUN_VELOCITY]<m_metric[PM__RUN_REVERSESLOWDOWN]; + moveVel.vx+=metrics->m_metric[PM__RUN_REVERSESLOWDOWN]; } + setMoveVelocity(&moveVel); } int CPlayerModeBase::slowdown() { const PlayerMetrics *metrics; + DVECTOR moveVel; int ret=false; - metrics=getPlayerMetrics(); - if(m_moveVelocity.vx<0) + metrics=getPlayerMetrics(); + moveVel=*m_player->getMoveVelocity(); + + if(moveVel.vx<0) { - m_moveVelocity.vx+=metrics->m_metric[PM__RUN_SLOWDOWN]; - if(m_moveVelocity.vx>=0) + moveVel.vx+=metrics->m_metric[PM__RUN_SLOWDOWN]; + if(moveVel.vx>=0) { - m_moveVelocity.vx=0; + moveVel.vx=0; ret=true; } } - else if(m_moveVelocity.vx>0) + else if(moveVel.vx>0) { - m_moveVelocity.vx-=metrics->m_metric[PM__RUN_SLOWDOWN]; - if(m_moveVelocity.vx<=0) + moveVel.vx-=metrics->m_metric[PM__RUN_SLOWDOWN]; + if(moveVel.vx<=0) { - m_moveVelocity.vx=0; + moveVel.vx=0; ret=true; } } @@ -542,22 +558,28 @@ int CPlayerModeBase::slowdown() // This should probly be considered a bug.. (pkg) ret=true; } + setMoveVelocity(&moveVel); return ret; } void CPlayerModeBase::jump() { - m_moveVelocity.vy=-getPlayerMetrics()->m_metric[PM__JUMP_VELOCITY]<getMoveVelocity(); + moveVel.vy=-getPlayerMetrics()->m_metric[PM__JUMP_VELOCITY]<getMoveVelocity(); - - m_moveVelocity.vy+=getPlayerMetrics()->m_metric[PM__GRAVITY]; - if(m_moveVelocity.vy>=metrics->m_metric[PM__TERMINAL_VELOCITY]<m_metric[PM__GRAVITY]; + if(moveVel.vy>=metrics->m_metric[PM__TERMINAL_VELOCITY]<m_metric[PM__TERMINAL_VELOCITY]<m_metric[PM__TERMINAL_VELOCITY]<m_metric[PM__BUTT_FALL_VELOCITY]<<(VELOCITY_SHIFT+1); - m_moveVelocity.vy=metrics->m_metric[buttfallspeed]<getMoveVelocity(); +// moveVel.vy=metrics->m_metric[PM__BUTT_FALL_VELOCITY]<<(VELOCITY_SHIFT+1); + moveVel.vy=metrics->m_metric[buttfallspeed]<