This commit is contained in:
Charles 2001-06-11 23:12:58 +00:00
parent f04edb8544
commit c616369ec5
7 changed files with 123 additions and 34 deletions

View File

@ -72,41 +72,68 @@ void CNpcCartPlatform::processMovement( int _frames )
}
}
// check for vertical movement
s32 checkDist = yMovement + 50;
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, checkDist );
if ( groundHeight < checkDist )
if ( m_inJump )
{
// groundHeight <= yMovement indicates either just above ground or on or below ground
m_vertSpeed += 64;
moveY = groundHeight;
if ( m_vertSpeed > ( 5 << 8 ) )
{
m_vertSpeed = 5 << 8;
}
else if ( m_vertSpeed < -( 6 << 8 ) )
{
m_vertSpeed = -( 6 << 8 );
}
moveY = ( m_vertSpeed >> 8 ) * _frames;
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
if ( groundHeight < 0 )
{
// have touched down
m_inJump = false;
}
}
else
{
// fall
// check for vertical movement
moveY = yMovement;
}
s32 checkDist = yMovement + 50;
if ( moveY < 0 )
{
m_carSpeed -= 20;
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, checkDist );
if ( m_carSpeed < ( 2 << 8 ) )
if ( groundHeight < checkDist )
{
m_carSpeed = ( 2 << 8 );
// groundHeight <= yMovement indicates either just above ground or on or below ground
moveY = groundHeight;
}
}
else if ( moveY > 0 )
{
m_carSpeed += 20;
if ( m_carSpeed > ( 6 << 8 ) )
else
{
m_carSpeed = ( 6 << 8 );
// fall
moveY = yMovement;
}
if ( moveY < 0 )
{
m_carSpeed -= 1;
if ( m_carSpeed < ( 2 << 8 ) )
{
m_carSpeed = ( 2 << 8 );
}
}
else if ( moveY > 0 )
{
m_carSpeed += 20;
if ( m_carSpeed > ( 6 << 8 ) )
{
m_carSpeed = ( 6 << 8 );
}
}
}
@ -200,3 +227,14 @@ void CNpcCartPlatform::render()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcCartPlatform::jump()
{
if ( !m_inJump )
{
m_inJump = true;
m_vertSpeed = -6 << 8;
}
}

View File

@ -23,11 +23,15 @@ class CNpcCartPlatform : public CNpcPlatform
public:
virtual void postInit();
virtual void render();
virtual u8 isCart() {return( true );}
virtual void jump();
protected:
virtual void processMovement( int _frames );
s32 m_carSpeed;
u8 m_isActivated;
u8 m_inJump;
s32 m_vertSpeed;
};
#endif

View File

@ -121,6 +121,8 @@ public:
void setGraphic( u8 graphicNum );
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void trigger() {;}
virtual u8 isCart() {return( false );}
virtual void jump() {;}
static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType );
static CNpcPlatform *Create(int Type);

View File

@ -728,18 +728,29 @@ if(newmode!=-1)
platform=isOnPlatform();
if(platform)
{
DVECTOR posDelta;
posDelta=platform->getPosDelta();
posDelta.vy = 0;
shove(posDelta);
int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
int height=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy,16);
if ( platformOffset < height )
if ( ( (CNpcPlatform *) platform )->isCart() )
{
Pos.vx = platform->getPos().vx;
Pos.vy = platform->getPos().vy;
int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
Pos.vy += platformOffset;
}
else
{
DVECTOR posDelta;
posDelta=platform->getPosDelta();
posDelta.vy = 0;
shove(posDelta);
int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
int height=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy,16);
if ( platformOffset < height )
{
Pos.vy += platformOffset;
}
}
}

View File

@ -70,6 +70,10 @@
#include "player\psspring.h"
#endif
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
#include "game/game.h"
/* Std Lib
------- */
@ -195,7 +199,19 @@ void CPlayerModeBase::think()
{
getStateTable()[m_currentState]->think(this);
thinkVerticalMovement();
thinkHorizontalMovement();
if ( m_player->isOnPlatform() )
{
CNpcPlatform *platform = (CNpcPlatform *) m_player->isOnPlatform();
if ( !platform->isCart() )
{
thinkHorizontalMovement();
}
}
else
{
thinkHorizontalMovement();
}
// Teeter if on an edge
if(canTeeter()&&isOnEdge())
@ -618,6 +634,24 @@ int CPlayerModeBase::slowdown()
}
void CPlayerModeBase::jump()
{
CNpcPlatform *platform;
platform = (CNpcPlatform *) m_player->isOnPlatform();
if(platform)
{
if ( platform->isCart() )
{
/*Pos.vx = platform->getPos().vx;
Pos.vy = platform->getPos().vy;
int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
Pos.vy += platformOffset;*/
platform->jump();
return;
}
}
DVECTOR moveVel;
moveVel=*m_player->getMoveVelocity();
moveVel.vy=-getPlayerMetrics()->m_metric[PM__JUMP_VELOCITY]<<VELOCITY_SHIFT;