Exemplo n.º 1
0
XMFLOAT2 Input::GetMovementVector() const
{
    float x = 0.0f;
    float y = 0.0f;

    GetLeftThumbStickValue(&x, &y);
    if (IsKeyDown('D'))
    {
        x = 1.0f;
    }
    if (IsKeyDown('A'))
    {
        x = -1.0f;
    }
    if (IsKeyDown('W'))
    {
        y = 1.0f;
    }
    if (IsKeyDown('S'))
    {
        y = -1.0f;
    }

    return XMFLOAT2(x, y);
}
void InputManager::Update()
{
	XMFLOAT2 leftThumbXY = GetLeftThumbStickValue();

	if ((GetRightTriggerValue() > 30) || (GetAsyncKeyState('W') & 0x8000))
	{
		m_Input=m_Input | 1;
	}
	else
	{
		m_Input=m_Input & ~1;
	}


	if ((GetLeftTriggerValue() >  30) || (GetAsyncKeyState(VK_SPACE)))
	{
		m_Input=m_Input | 2;
	}
	else
	{
		m_Input=m_Input & ~2;
	}


	if ((leftThumbXY.x < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) || (GetAsyncKeyState('A') & 0x8000))
	{
		m_Input=m_Input | 4;
	}
	else
	{
		m_Input=m_Input & ~4;
	}


	if ((leftThumbXY.x > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) || (GetAsyncKeyState('D') & 0x8000))
	{
		m_Input=m_Input | 8;
	}
	else
	{
		m_Input=m_Input & ~8;
	}

	if ((GetKeyState(XINPUT_GAMEPAD_START)) || (GetAsyncKeyState(VK_ESCAPE)))
	{
		m_Input=m_Input | 16;
	}
	else
	{
		m_Input=m_Input & ~16;
	}

	if ((GetKeyState(XINPUT_GAMEPAD_LEFT_SHOULDER)) || (GetAsyncKeyState(VK_LSHIFT)))
	{
		m_Input=m_Input | 32;
	}
	else
	{
		m_Input=m_Input & ~32;
	}

	if ((GetKeyState(XINPUT_GAMEPAD_B)) || (GetAsyncKeyState(VK_UP)))
	{
		m_Input=m_Input | 64;
	}
	else
	{
		m_Input=m_Input & ~64;
	}

	if ((GetKeyState(XINPUT_GAMEPAD_X)) || (GetAsyncKeyState(VK_DOWN)))
	{
		m_Input=m_Input | 128;
	}
	else
	{
		m_Input=m_Input & ~128;
	}
}