diff --git a/source/player/player.cpp b/source/player/player.cpp index b643d29f4..f56fa8267 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -300,8 +300,6 @@ char posBuf[100]; void CPlayer::think(int _frames) { int i; - - CPlayerThing::think(_frames); if(PadGetHeld(0)&PAD_L1&&PadGetHeld(0)&PAD_L2) @@ -413,6 +411,8 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64; m_cameraPos.vy=m_mapCameraEdges.vy; m_cameraScrollDir=0; } + + CPlayerThing::think(_frames); } diff --git a/source/player/pmodes.cpp b/source/player/pmodes.cpp index 711c4e251..65a9b44ca 100644 --- a/source/player/pmodes.cpp +++ b/source/player/pmodes.cpp @@ -323,6 +323,31 @@ void CPlayerModeBase::thinkVerticalMovement() { pos.vy += 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); + } } } diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index f928589b8..f2d301b68 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -139,7 +139,7 @@ void CThingManager::thinkAllThings(int _frames) thing1->removeAllChild(); if(thing1->canCollide()&& - thing1->checkCollisionAgainst(thing2)) + thing1->checkCollisionAgainst(thing2, _frames)) { thing1->addChild( thing2 ); @@ -164,7 +164,7 @@ void CThingManager::thinkAllThings(int _frames) while(thing1&&thing2) { if(thing1->canCollide()&& - thing1->checkCollisionAgainst(thing2)) + thing1->checkCollisionAgainst(thing2, _frames)) { thing1->collidedWith(thing2); } @@ -177,7 +177,7 @@ void CThingManager::thinkAllThings(int _frames) while(thing1&&thing2) { if(thing1->canCollide()&& - thing1->checkCollisionAgainst(thing2)) + thing1->checkCollisionAgainst(thing2, _frames)) { thing1->collidedWith(thing2); } @@ -190,7 +190,7 @@ void CThingManager::thinkAllThings(int _frames) while(thing1&&thing2) { if(thing1->canCollide()&& - thing1->checkCollisionAgainst(thing2)) + thing1->checkCollisionAgainst(thing2, _frames)) { thing1->collidedWith(thing2); } @@ -203,7 +203,7 @@ void CThingManager::thinkAllThings(int _frames) while(thing1&&thing2) { if(thing1->canCollide()&& - thing1->checkCollisionAgainst(thing2)) + thing1->checkCollisionAgainst(thing2, _frames)) { thing1->collidedWith(thing2); } @@ -347,9 +347,9 @@ void CThing::shutdown() ---------------------------------------------------------------------- */ void CThing::think(int _frames) { - DVECTOR PosLast=Pos; PosDelta.vx=Pos.vx-PosLast.vx; PosDelta.vy=Pos.vy-PosLast.vy; + PosLast=Pos; } /*---------------------------------------------------------------------- @@ -705,7 +705,7 @@ s32 CThing::getNewYPos(CThing *_thisThing) Params: Returns: ---------------------------------------------------------------------- */ -int CThing::checkCollisionAgainst(CThing *_thisThing) +int CThing::checkCollisionAgainst(CThing *_thisThing, int _frames) { DVECTOR pos,thisThingPos; int radius; @@ -783,12 +783,10 @@ int CThing::checkCollisionAgainst(CThing *_thisThing) { thatPos.vy = getNewYPos( _thisThing ); - if ( thatPos.vy - _thisThing->getPos().vy >= -10 ) + s32 verticalDelta = abs( _thisThing->getPosDelta().vy ); + + if ( thatPos.vy - _thisThing->getPos().vy >= -verticalDelta ) { - _thisThing->setHasPlatformCollided( true ); - - _thisThing->setCentreCollision( true ); - if ( _thisThing->getHasPlatformCollided() ) { // if this has already collided with a platform, check the current platform is @@ -797,13 +795,21 @@ int CThing::checkCollisionAgainst(CThing *_thisThing) DVECTOR oldCollidedPos = _thisThing->getNewCollidedPos(); - if ( thatPos.vy < oldCollidedPos.vy ) + s32 oldY = abs( oldCollidedPos.vy - ( _thisThing->getPos().vy - verticalDelta ) ); + s32 currentY = abs( thatPos.vy - ( _thisThing->getPos().vy - verticalDelta ) ); + + //if ( thatPos.vy < oldCollidedPos.vy ) + if ( currentY < oldY ) { _thisThing->setNewCollidedPos( thatPos ); } } else { + _thisThing->setHasPlatformCollided( true ); + + _thisThing->setCentreCollision( true ); + _thisThing->setNewCollidedPos( thatPos ); } } diff --git a/source/thing/thing.h b/source/thing/thing.h index ec1e0452e..1eef2e3fe 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -100,6 +100,7 @@ public: DVECTOR getPos() {return Pos;} void setPos(DVECTOR newPos) {Pos=newPos;} + DVECTOR getPosDelta() {return PosDelta;} virtual void shove(DVECTOR move); CThing *getNext() {return Next;} @@ -114,7 +115,7 @@ protected: CThing *Parent,*Next; // Pos - DVECTOR Pos, PosDelta; + DVECTOR Pos, PosLast, PosDelta; public: class CThing *m_nextThing; @@ -126,7 +127,7 @@ public: // -- Collision -- public: virtual int canCollide() {return true;} - virtual int checkCollisionAgainst(CThing *_thisThing); + virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); void updateCollisionArea(); virtual void collidedWith(CThing *_thisThing) {;} virtual void setHasPlatformCollided( bool newVal ) {;}