本文整理汇总了C++中CBase::GetVelX方法的典型用法代码示例。如果您正苦于以下问题:C++ CBase::GetVelX方法的具体用法?C++ CBase::GetVelX怎么用?C++ CBase::GetVelX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBase
的用法示例。
在下文中一共展示了CBase::GetVelX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void CCamera::Update( float fElapsedTime )
{
int width( int( theCamera->GetWidth( )-theCamera->GetXOffset( ) ) );
int height( int( theCamera->GetHeight( )-theCamera->GetYOffset( ) ) );
RECT rCamera;
rCamera.left = LONG( GetXOffset() );
rCamera.right = LONG( rCamera.left + GetWidth() );
rCamera.top = LONG( GetYOffset() );
rCamera.bottom = LONG( rCamera.top + GetHeight() );
CBase* pCurPlayer;
RECT rPlayer;
if( !((CPlayer*)thePlayer)->GetFainted() || thePlayer2 == NULL )
{
pCurPlayer = thePlayer;
rPlayer = thePlayer->GetCollisionRect( fElapsedTime );
}
else if( thePlayer2 )
{
pCurPlayer = thePlayer2;
rPlayer = thePlayer2->GetCollisionRect( fElapsedTime );
}
int CenterOfScreenX( int( theCamera->GetXOffset( ) + width / 2 ) );
int CenterOfScreenY( int( theCamera->GetYOffset( ) + height / 2 ) );
RECT rHook, r;
int x = thePlayer->GetWidth( );
rHook.left = CenterOfScreenX - ( thePlayer->GetWidth( ) << 1 );
rHook.top = CenterOfScreenY - ( thePlayer->GetHeight( ) );
rHook.right = CenterOfScreenX + ( thePlayer->GetWidth( ) << 1 );
rHook.bottom = CenterOfScreenY + ( thePlayer->GetHeight( ) );
if( !IntersectRect( &r, &rPlayer, &rCamera ) )
{
theCamera->SetCameraXOffset( pCurPlayer->GetPosX( ) - width / 2 );
theCamera->SetCameraYOffset( pCurPlayer->GetPosY( ) - height / 2 );
}
if (IntersectRect( &r, &rHook, &rPlayer ) )
{
theCamera->SetVelocityX( theCamera->GetVelocityX( ) * 0.95f );
theCamera->SetVelocityY( theCamera->GetVelocityY( ) * 0.95f );
}
{
if( rPlayer.left < rHook.left && pCurPlayer->GetVelX() < -110)
theCamera->SetVelocityX( pCurPlayer->GetVelX());
else if( rPlayer.left < rHook.left )
theCamera->SetVelocityX( -100 );
else if( rPlayer.right > rHook.right && pCurPlayer->GetVelX() > 110)
theCamera->SetVelocityX( pCurPlayer->GetVelX() );
else if( rPlayer.right > rHook.right )
theCamera->SetVelocityX( 100 );
if( rPlayer.top < rHook.top )
theCamera->SetVelocityY( -100 );
else if( rPlayer.bottom > rHook.bottom && pCurPlayer->GetVelY() > 200)
theCamera->SetVelocityY( pCurPlayer->GetVelY() );
else if(rPlayer.bottom > rHook.bottom)
theCamera->SetVelocityY( 200 );
}
theCamera->SetCameraXOffset( theCamera->GetXOffset( ) + theCamera->GetVelocityX( ) * fElapsedTime );
theCamera->SetCameraYOffset( theCamera->GetYOffset( ) + theCamera->GetVelocityY( ) * fElapsedTime );
}