Пример #1
0
void GameAsteroid::CalculateParameters(bool moveToCenter, Vector3 direction, float randomMuliplier)
{
    Vector2 toCenter = Vector2Make(0, 0);
    Vector2 center = _delegate->FieldCenter();
    if (moveToCenter) {
        Vector2 position = GetPosition();
        toCenter = Vector2Subtract(center, position);
        toCenter = Vector2Normalize(toCenter);
    }
    Vector2 random = Vector2Make(cosf(_random), sinf(_random));
    
    
    _moveVector = Vector3Make(toCenter.x * 2.0 + random.x *randomMuliplier + direction.x  , toCenter.y * 2.0 + random.y * randomMuliplier + direction.y, 0);
    
    float timex = center.x / _moveVector.x;
    float timey = center.y / _moveVector.y;
    float time = ____max(timey, timex) / 7;
    _existTimer = new MAXAnimationWait(time);
    _existTimer->_delegate = this;
    MAXAnimationManager::SharedAnimationManager()->AddAnimation(_existTimer);
    
}
Пример #2
0
void CRenderWnd::OnMouseMove(UINT nFlags, CPoint point) 
{
	float xzAdd, yAdd, distanceAdd;
	static float turnSpeed = 0.3f;
	static float distanceSpeed = 0.3f;

	static DWORD lastTick = 0;
	DWORD holdTime;
	float timeAdjust;

	if ((point != m_ptTracking) && (m_bTracking))
	{
		if (!lastTick)
			lastTick = timeGetTime();
		holdTime = timeGetTime();
		timeAdjust = ____max((float)(holdTime - lastTick) / 10.0f, 1.0f); // t.f (don'task)
		lastTick = holdTime;
	}

	bool alterCamera = false;
	bool alterLight[2] = {false,false};

	if( m_bCameraFollow )
	{
		alterCamera = true;
		alterLight[0] = alterLight[1] = true;
	}
	else if( GetAsyncKeyState( VK_CONTROL ) & 0x8000 )
	{
		if( GetAsyncKeyState( VK_SHIFT ) & 0x8000 )
			alterLight[1] = true;
		else
			alterLight[0] = true;
	}
	else
	{
		alterCamera = true;
	}

	if (m_bTracking && (nFlags & MK_LBUTTON) && (nFlags & MK_RBUTTON) && point != m_ptTracking)
	{
		xzAdd = m_Scale * (float)(m_ptTracking.x - point.x) / timeAdjust;
		yAdd = m_Scale * (float)(m_ptTracking.y - point.y) / timeAdjust;

		m_Camera.m_Offset.x += xzAdd;
		m_Camera.m_Offset.y += yAdd;
		m_Camera.Update();
		
		SetCursorPos (m_ptTrackingScreen.x, m_ptTrackingScreen.y);
	}
	else if (m_bTracking && (nFlags & MK_LBUTTON) && point != m_ptTracking)
	{
		xzAdd = turnSpeed * (float)(m_ptTracking.x - point.x);
		yAdd = turnSpeed * (float)(point.y - m_ptTracking.y);

		if( alterCamera )
		{
			m_Camera.m_fXZAngle += xzAdd;
			m_Camera.m_fYAngle += yAdd;
			m_Camera.Update();
		}

		if( alterLight[0] )
		{
			m_LightLocators[0].m_nXZAngle += xzAdd;
			m_LightLocators[0].m_nYAngle += yAdd;
			m_LightLocators[0].UpdateLocation();
		}

		if( alterLight[1] )
		{
			m_LightLocators[1].m_nXZAngle += xzAdd;
			m_LightLocators[1].m_nYAngle += yAdd;
			m_LightLocators[1].UpdateLocation();
		}
		
		SetCursorPos (m_ptTrackingScreen.x, m_ptTrackingScreen.y);
	}
	else if (m_bTracking && (nFlags & MK_RBUTTON) && point.y != m_ptTracking.y)
	{
		distanceAdd = distanceSpeed * (float)(point.y - m_ptTracking.y) / timeAdjust;
		distanceAdd *= m_Scale;

		if( alterCamera )
		{
			m_Camera.m_Position.z += distanceAdd;
			m_Camera.Update();
		}

		if( alterLight[0] )
		{
			m_LightLocators[0].m_nDistance += distanceAdd;
			m_LightLocators[0].UpdateLocation();
		}

		if( alterLight[1] )
		{
			m_LightLocators[1].m_nDistance += distanceAdd;
			m_LightLocators[1].UpdateLocation();
		}

		SetCursorPos (m_ptTrackingScreen.x, m_ptTrackingScreen.y);
	}

	CWnd::OnMouseMove(nFlags, point);
}