From ec79151e931d8fd8d711e8524f4565c8e2549b02 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 31 Jul 2001 21:25:11 +0000 Subject: [PATCH] --- source/platform/psbarrel.cpp | 108 ++++++++++++----------------------- source/platform/psoil.h | 4 +- 2 files changed, 37 insertions(+), 75 deletions(-) diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index 713ff0888..437da0af9 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -60,78 +60,13 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) s32 playerMovement = player->getMovement(); - /*s32 speedChange = -playerVel->vx << 8; - - if ( speedChange > ( _frames << 5 ) ) - { - speedChange = _frames << 5; - } - else if ( speedChange < -( _frames << 5 ) ) - { - speedChange = -_frames << 5; - } - - m_currentSpeed += speedChange; - - if ( m_currentSpeed > ( m_speed << 8 ) ) - { - m_currentSpeed = ( m_speed << 8 ); - } - else if ( m_currentSpeed < -( m_speed << 8 ) ) - { - m_currentSpeed = -( m_speed << 8 ); - }*/ - m_currentSpeed = -playerMovement; - - /*s32 playerX = playerPos.vx - this->Pos.vx; - - if ( playerX > 5 ) - { - // increase barrel speed to right - - m_currentSpeed += _frames << 2; - - if ( m_currentSpeed > ( m_speed << 8 ) ) - { - m_currentSpeed = ( m_speed << 8 ); - } - } - else if ( playerX < -5 ) - { - m_currentSpeed -= _frames << 2; - - if ( m_currentSpeed < -( m_speed << 8 ) ) - { - m_currentSpeed = -( m_speed << 8 ); - } - }*/ } else { - // reduce speed - - /*s32 speedReduce = -m_currentSpeed; - - if ( speedReduce > _frames ) - { - speedReduce = _frames; - } - else if ( speedReduce < -_frames ) - { - speedReduce = -_frames; - } - - m_currentSpeed += speedReduce;*/ - m_currentSpeed = 0; } - /*m_moveXHighRes += m_currentSpeed * _frames; - - moveX = m_moveXHighRes >> 8; - m_moveXHighRes -= moveX << 8;*/ - moveX = m_currentSpeed; if ( m_currentSpeed ) @@ -142,14 +77,6 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) } } - // check for collision - - if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy ) < -maxHeight ) - { - moveX = 0; - m_currentSpeed = 0; - } - m_rotation += ( m_currentSpeed * 30 * _frames ) >> 2; m_rotation &= 4095; @@ -161,6 +88,41 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) player->shove(shove); } + // check for collision + + if ( moveX ) + { + int remainder = abs( moveX ); + int sign = moveX / abs( moveX ); + int testX = 0; + + while ( remainder ) + { + if ( remainder > 16 ) + { + remainder -= 16; + testX += 16 * sign; + } + else + { + testX += remainder * sign; + remainder = 0; + } + + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + testX, Pos.vy ) < -maxHeight ) + { + moveX = 0; + m_currentSpeed = 0; + } + } + } + + /*if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy ) < -maxHeight ) + { + moveX = 0; + m_currentSpeed = 0; + }*/ + // check for vertical movement groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 ); diff --git a/source/platform/psoil.h b/source/platform/psoil.h index 287820727..b655bb256 100644 --- a/source/platform/psoil.h +++ b/source/platform/psoil.h @@ -20,8 +20,8 @@ class CNpcSteerableOildrumPlatform : public CNpcSteerableBarrelPlatform { -protected: - void processMovement( int _frames ); +//protected: + //void processMovement( int _frames ); }; #endif \ No newline at end of file