Exemplo n.º 1
0
//-----------------------------------------------------------------------------------------------------------------------------------
void LevelDesignDecal::HandleInput(float elapsedSeconds, const Vector2& mousePosition)
{
  LevelDesignObject::HandleInput(elapsedSeconds, mousePosition);

  if (AcceptsInput())
  {
    if (IsSelected())
    {
      if (ScreenManager::GetKeyboardInput().IsKeyDown(Keyboard::A))
      {
        SetLocalRotation(GetLocalRotation() - 0.01f);
      }

      if (ScreenManager::GetKeyboardInput().IsKeyDown(Keyboard::D))
      {
        SetLocalRotation(GetLocalRotation() + 0.01f);
      }
    }
  }
}
Exemplo n.º 2
0
	void FreeCamera::Update(const Context& context)
	{
		if(m_pCamera->IsActive())
		{
			//HANDLE INPUT
			vec3 move = vec3(0,0,0);
			vec2 look = vec2(0,0);

#ifdef DESKTOP
			if(!m_bisStatic)
			{
				move.y = InputManager::GetInstance()->IsKeyboardKeyDown('Z') ? 1.0f : 0.0f;
				if(move.y == 0) 
				{
					move.y = -(InputManager::GetInstance()->IsKeyboardKeyDown('S') ? 1.0f : 0.0f);
				}
				if(move.y == 0) 
				{
					move.y = InputManager::GetInstance()->GetThumbstickPosition().y;
				}

				move.x = InputManager::GetInstance()->IsKeyboardKeyDown('D') ? 1.0f : 0.0f;
				if(move.x == 0) 
				{
					move.x = -(InputManager::GetInstance()->IsKeyboardKeyDown('Q') ? 1.0f : 0.0f);
				}
				//if it's still 0, that's why second check
				if(move.x == 0) 
				{
					move.x = InputManager::GetInstance()->GetThumbstickPosition().x;
				}

				//if no keyboard input, check controller input
				if(look.x == 0 && look.y == 0)
				{
					look = InputManager::GetInstance()->GetThumbstickPosition(false);
					look.y *= -1;
				}
			}
			if(m_bZoom)
			{
				if(InputManager::GetInstance()->IsKeyboardKeyDown('O'))
				{
					m_Zoom += m_ZoomSpeed * static_cast<float32>(context.mTimeManager->GetSeconds());
					m_pCamera->SetZoom(m_Zoom);
				}
				else if(InputManager::GetInstance()->IsKeyboardKeyDown('P'))
				{
					m_Zoom -= m_ZoomSpeed * static_cast<float32>(context.mTimeManager->GetSeconds());
					m_pCamera->SetZoom(m_Zoom);
				}
			}
#endif
			if(move != vec3() || look != vec2())
			{
				//CALCULATE TRANSFORMS
				auto transform = GetComponent<TransformComponent>();
				auto currPos = transform->GetLocalPosition();
				auto currRot = transform->GetLocalRotation();
				
				float64 deltaTime = context.mTimeManager->GetSeconds();
				move *= m_MoveSpeed * deltaTime;
	
				currPos.y += static_cast<float32>(move.y);
				currPos.x += static_cast<float32>(move.x);

				transform->Translate(currPos);
			}
		}
	}