Ejemplo n.º 1
0
void Camera::update( const float fDelta )
{
	static const float fMaxSpeed = 100.f;
	Vector2f vToTarget;
	if( m_eFollowMode == FOLLOW_ACTOR )
	{
		if( m_pFollowTarget != nullptr )
		{
			const Vector2f& vTargetPosition = m_pFollowTarget->GetPosition();
			vToTarget = vTargetPosition - m_vCameraCenter;
		}
	}
	else if( m_eFollowMode == FOLLOW_POSITION )
	{
		vToTarget = m_vSetFollowPosition - m_vCameraCenter;
	}
	if( ( fMaxSpeed * fMaxSpeed ) < vToTarget.Length2() )
		{
			vToTarget = vToTarget.Normalize() * fMaxSpeed;
		}
	m_vCameraCenter += vToTarget * fDelta;
}