当前位置: 首页>>代码示例>>C++>>正文


C++ Vector2::Direction方法代码示例

本文整理汇总了C++中Vector2::Direction方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::Direction方法的具体用法?C++ Vector2::Direction怎么用?C++ Vector2::Direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector2的用法示例。


在下文中一共展示了Vector2::Direction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MakeLookDisc

Vector2 Controller::MakeLookDisc(const Mathematics::Vector2 p_ScreenCentre) const
{
	Vector2 ret = m_States.MouseAndKeyboard().Position - p_ScreenCentre;
	ret = (ret.LengthSquared() > deadDist * deadDist) ? ret : Zero2();
	//ret += m_States.Gamepad().RightStick;

	return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
开发者ID:jarrodmky,项目名称:SimulacraEngine,代码行数:8,代码来源:Controller.cpp

示例2: MakeMoveDisc

Vector2 Controller::MakeMoveDisc() const
{
	Vector2 ret = Zero2();
	ret(0) = MakeAxisFromKeys(KeyboardKey::A, KeyboardKey::D);
	ret(1) = MakeAxisFromKeys(KeyboardKey::S, KeyboardKey::W);
	ret += m_States.Gamepad().LeftStick;

	return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
开发者ID:jarrodmky,项目名称:SimulacraEngine,代码行数:9,代码来源:Controller.cpp

示例3: Update

void InputState::Update()
{
	Reset();
	m_System->Update();

	//buttons

	if (m_System->IsKeyDown(Keys::SPACE) || m_System->IsGamePadButtonDown(Xbox::A))
	{
		m_ActionPressed = true;
	}

	if (m_System->IsKeyDown(Keys::ENTER) || m_System->IsGamePadButtonDown(Xbox::X))
	{
		m_ConfirmPressed = true;
	}

	if (m_System->IsKeyDown(Keys::ESCAPE) || m_System->IsGamePadButtonDown(Xbox::Y))
	{
		m_DenyPressed = true;
	}

	if(m_System->IsKeyDown(Keys::F1))
	{
		m_FullscreenPressed = true;
	}
	
	//axes or discs

	Vector2 leftRaw;
	Vector2 rightRaw;

	if (m_System->GamepadIsConnected())
	{
		leftRaw(1) = -m_System->GetLeftAnalogX();
		leftRaw(2) = m_System->GetLeftAnalogY();
		rightRaw(1) = m_System->GetRightAnalogX();
		rightRaw(2) = m_System->GetRightAnalogY();

		m_LeftDisc = leftRaw - m_LeftDiscCentre;
		m_RightDisc = rightRaw - m_LeftDiscCentre;
	}
	else
	{
		if (m_System->IsKeyDown(Keys::A))
		{
			leftRaw += U();
		}

		if (m_System->IsKeyDown(Keys::D))
		{
			leftRaw += -U();
		}

		if (m_System->IsKeyDown(Keys::W))
		{
			leftRaw += V();
		}

		if (m_System->IsKeyDown(Keys::S))
		{
			leftRaw += -V();
		}

		if (m_System->IsKeyDown(Keys::LEFT))
		{
			rightRaw += -U();
		}

		if (m_System->IsKeyDown(Keys::RIGHT))
		{
			rightRaw += U();
		}

		if (m_System->IsKeyDown(Keys::UP))
		{
			rightRaw += V();
		}

		if (m_System->IsKeyDown(Keys::DOWN))
		{
			rightRaw += -V();
		}

		if (!EquivalentToZero(leftRaw.LengthSquared()))
		{
			m_LeftDisc = leftRaw.Direction();
		}

		if (!EquivalentToZero(rightRaw.LengthSquared()))
		{
			m_RightDisc = rightRaw.Direction();
		}
	}
}
开发者ID:jarrodmky,项目名称:SimulacraEngine,代码行数:95,代码来源:InputState.cpp


注:本文中的Vector2::Direction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。