This commit is contained in:
parent
f67b64565d
commit
12567cce7a
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 ) {;}
|
||||
|
Loading…
Reference in New Issue
Block a user