This commit is contained in:
parent
ef121cdaf8
commit
b0ac20da10
3 changed files with 97 additions and 57 deletions
|
@ -288,7 +288,8 @@ int CLayerCollision::getHeightFromGroundCart(int _x,int _y,int _maxHeight)
|
||||||
distanceFromGround=0;
|
distanceFromGround=0;
|
||||||
|
|
||||||
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
||||||
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE )
|
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE ||
|
||||||
|
(Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DEATH_FALL )
|
||||||
{
|
{
|
||||||
colHeight = 0;
|
colHeight = 0;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +306,8 @@ int CLayerCollision::getHeightFromGroundCart(int _x,int _y,int _maxHeight)
|
||||||
return -_maxHeight;
|
return -_maxHeight;
|
||||||
}
|
}
|
||||||
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
||||||
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE )
|
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE ||
|
||||||
|
(Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DEATH_FALL )
|
||||||
{
|
{
|
||||||
colHeight = 0;
|
colHeight = 0;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +329,8 @@ int CLayerCollision::getHeightFromGroundCart(int _x,int _y,int _maxHeight)
|
||||||
return _maxHeight;
|
return _maxHeight;
|
||||||
}
|
}
|
||||||
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
colHeight=s_collisionTable[((Map[mapX+mapY]&COLLISION_TILE_MASK)*16)+xFraction];
|
||||||
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE )
|
if ( (Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DAMAGE ||
|
||||||
|
(Map[mapX+mapY] & COLLISION_TYPE_MASK) == COLLISION_TYPE_FLAG_DEATH_FALL )
|
||||||
{
|
{
|
||||||
colHeight = 0;
|
colHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,10 @@ void CNpcCartPlatform::postInit()
|
||||||
calculateNonRotatedCollisionData();
|
calculateNonRotatedCollisionData();
|
||||||
|
|
||||||
m_playerAttached = false;
|
m_playerAttached = false;
|
||||||
|
m_falling = false;
|
||||||
m_rebound = false;
|
m_rebound = false;
|
||||||
m_reboundTimer = 0;
|
m_reboundTimer = 0;
|
||||||
|
m_inJump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,7 +69,7 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
m_reboundTimer -= _frames;
|
m_reboundTimer -= _frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_playerAttached )
|
if ( !m_playerAttached && !m_falling )
|
||||||
{
|
{
|
||||||
m_playerAttached = true;
|
m_playerAttached = true;
|
||||||
CPlayer *player = GameScene.getPlayer();
|
CPlayer *player = GameScene.getPlayer();
|
||||||
|
@ -83,15 +85,37 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
|
|
||||||
if ( m_isActivated )
|
if ( m_isActivated )
|
||||||
{
|
{
|
||||||
if ( m_rebound )
|
if ( m_falling )
|
||||||
|
{
|
||||||
|
m_vertSpeed += 192;
|
||||||
|
|
||||||
|
if ( m_vertSpeed > ( 8 << 8 ) )
|
||||||
|
{
|
||||||
|
m_vertSpeed = 8 << 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
||||||
|
|
||||||
|
Pos.vy += moveY;
|
||||||
|
|
||||||
|
DVECTOR offset = CLevel::getCameraPos();
|
||||||
|
|
||||||
|
s32 yPos = Pos.vy - offset.vy;
|
||||||
|
|
||||||
|
if ( yPos < 0 || yPos > VidGetScrH() )
|
||||||
|
{
|
||||||
|
setToShutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( m_rebound )
|
||||||
{
|
{
|
||||||
moveX = -4 * _frames;
|
moveX = -4 * _frames;
|
||||||
|
|
||||||
m_vertSpeed += 192;
|
m_vertSpeed += 192;
|
||||||
|
|
||||||
if ( m_vertSpeed > ( 5 << 8 ) )
|
if ( m_vertSpeed > ( 8 << 8 ) )
|
||||||
{
|
{
|
||||||
m_vertSpeed = 5 << 8;
|
m_vertSpeed = 8 << 8;
|
||||||
}
|
}
|
||||||
else if ( m_vertSpeed < -( 6 << 8 ) )
|
else if ( m_vertSpeed < -( 6 << 8 ) )
|
||||||
{
|
{
|
||||||
|
@ -142,9 +166,9 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
|
|
||||||
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
||||||
|
|
||||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx + moveX, Pos.vy, moveY + 16 );
|
||||||
|
|
||||||
if ( groundHeight < 0 )
|
if ( groundHeight < moveY )
|
||||||
{
|
{
|
||||||
// have touched down
|
// have touched down
|
||||||
|
|
||||||
|
@ -186,9 +210,9 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
{
|
{
|
||||||
m_carSpeed += 20;
|
m_carSpeed += 20;
|
||||||
|
|
||||||
if ( m_carSpeed > ( 6 << 8 ) )
|
if ( m_carSpeed > ( 5 << 8 ) )
|
||||||
{
|
{
|
||||||
m_carSpeed = ( 6 << 8 );
|
m_carSpeed = ( 5 << 8 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,16 +258,25 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
|
|
||||||
setCollisionAngle( heading );
|
setCollisionAngle( heading );
|
||||||
|
|
||||||
if ( m_reboundTimer <= 0 )
|
|
||||||
{
|
|
||||||
switch ( CGameScene::getCollision()->getCollisionBlock( testPos2.vx, testPos2.vy - 8 ) & COLLISION_TYPE_MASK )
|
switch ( CGameScene::getCollision()->getCollisionBlock( testPos2.vx, testPos2.vy - 8 ) & COLLISION_TYPE_MASK )
|
||||||
{
|
{
|
||||||
case COLLISION_TYPE_FLAG_DAMAGE:
|
case COLLISION_TYPE_FLAG_DAMAGE:
|
||||||
|
{
|
||||||
|
if ( m_reboundTimer <= 0 )
|
||||||
{
|
{
|
||||||
m_vertSpeed = -8 << 8;
|
m_vertSpeed = -8 << 8;
|
||||||
m_reboundTimer = 2 * GameState::getOneSecondInFrames();
|
m_reboundTimer = 2 * GameState::getOneSecondInFrames();
|
||||||
m_rebound = true;
|
m_rebound = true;
|
||||||
Pos.vy -= 8;
|
Pos.vy -= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COLLISION_TYPE_FLAG_DEATH_FALL:
|
||||||
|
{
|
||||||
|
m_playerAttached = false;
|
||||||
|
m_falling = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +285,6 @@ void CNpcCartPlatform::processMovement( int _frames )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx, Pos.vy, yMovement + 16 );
|
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
@ -318,6 +350,8 @@ void CNpcCartPlatform::jump()
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcCartPlatform::collidedWith( CThing *_thisThing )
|
void CNpcCartPlatform::collidedWith( CThing *_thisThing )
|
||||||
|
{
|
||||||
|
if ( !m_falling )
|
||||||
{
|
{
|
||||||
switch(_thisThing->getThingType())
|
switch(_thisThing->getThingType())
|
||||||
{
|
{
|
||||||
|
@ -378,3 +412,4 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
void render();
|
void render();
|
||||||
u8 isCart() {return( true );}
|
u8 isCart() {return( true );}
|
||||||
void jump();
|
void jump();
|
||||||
|
bool alwaysThink() {return(true);}
|
||||||
protected:
|
protected:
|
||||||
void processMovement( int _frames );
|
void processMovement( int _frames );
|
||||||
void collidedWith(CThing *_thisThing);
|
void collidedWith(CThing *_thisThing);
|
||||||
|
@ -35,6 +36,7 @@ protected:
|
||||||
s32 m_vertSpeed;
|
s32 m_vertSpeed;
|
||||||
u8 m_playerAttached;
|
u8 m_playerAttached;
|
||||||
u8 m_rebound;
|
u8 m_rebound;
|
||||||
|
u8 m_falling;
|
||||||
|
|
||||||
s32 m_reboundTimer;
|
s32 m_reboundTimer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue