コード例 #1
0
bool LoadState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if (pInput->IsKeyPressed(SGD::Key::Escape) || pInput->IsButtonDown(0, 6))
	{
		Game::GetInstance()->RemoveState();
	}

	if (pInput->GetCursorMovement().x || pInput->GetCursorMovement().y)
	{
		if (pInput->GetCursorPosition().IsPointInRectangle(newRect))
			m_nCursor = 0;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot1))
			m_nCursor = 1;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot2))
			m_nCursor = 2;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot3))
			m_nCursor = 3;
		else if (pInput->GetCursorPosition().IsPointInRectangle(exit))
			m_nCursor = 4;
		else
			m_nCursor = -1;
	}
	if (m_fArcadeTimer >= 1.0f)
	{
		if (pInput->IsKeyPressed(SGD::Key::Left) || pInput->IsKeyPressed(SGD::Key::A) || pInput->GetLeftJoystick(0).x == -1)
		{
			m_nCursor--;
			if (m_nCursor < 0)
				m_nCursor = 4;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Right) || pInput->IsKeyPressed(SGD::Key::D) || pInput->GetLeftJoystick(0).x == 1)
		{
			m_nCursor++;
			if (m_nCursor > 4)
				m_nCursor = 0;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Up) || pInput->IsKeyPressed(SGD::Key::W) || pInput->GetLeftJoystick(0).y == -1)
		{
			m_nCursor--;
			if (m_nCursor < 0)
				m_nCursor = 4;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Down) || pInput->IsKeyPressed(SGD::Key::S) || pInput->GetLeftJoystick(0).y == 1)
		{
			m_nCursor++;
			if (m_nCursor > 4)
				m_nCursor = 0;

			m_fArcadeTimer = 0.0f;

		}
	}

	if (pInput->IsKeyPressed(SGD::Key::Enter) || pInput->IsKeyPressed(SGD::Key::MouseLeft) || pInput->IsButtonDown(0, 0))
	{
		switch (m_nCursor)
		{
		case 0:
			Game::GetInstance()->AddState(GameplayState::GetInstance());
			break;
		case 1:
			Load("resource/Save/Save.xml");
			break;
		case 2:
			Load2("resource/Save/Save2.xml");
			break;
		case 3:
			Load3("resource/Save/Save3.xml");
			break;
		case 4:
			Game::GetInstance()->RemoveState();
			break;
		default:
			break;
		}
	}

	return true;
}
コード例 #2
0
ファイル: ProfileSelectState.cpp プロジェクト: Fiercy/evoark
void CProfileSelectState::SeletionInput()
{
	SGD::InputManager* input = SGD::InputManager::GetInstance();
#if ARCADE
	if (input->IsButtonPressed(0, 6) || input->IsButtonPressed(1, 6) || input->IsButtonPressed(0, 2) || input->IsButtonPressed(1, 2))
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		return;
	}

	SGD::Vector joy1 = input->GetLeftJoystick(0);
	SGD::Vector joy2 = input->GetLeftJoystick(1);
	if (joy1.x > 0 || joy2.x > 0)
	{
		if (currentProfile >= 2)
			currentProfile = 0;
		else
			currentProfile++;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (joy1.x < 0 || joy2.x < 0)
	{
		if (currentProfile <= 0)
			currentProfile = 2;
		else
			currentProfile--;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsButtonPressed(0, 0) || input->IsButtonPressed(1, 0))
	{
		state = MyState::Menu;
	}

	if (input->IsKeyPressed(SGD::Key::MouseLeft))
	{
		SGD::Point mouse = input->GetMousePosition();
		if (mouse.IsWithinRectangle(SGD::Rectangle{ current, profileSize }))
		{
			state = MyState::Menu;
			return;
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ next, profileSize }))
		{
			if (currentProfile >= 2)
				currentProfile = 0;
			else
				currentProfile++;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ previous, profileSize }))
		{
			if (currentProfile <= 0)
				currentProfile = 2;
			else
				currentProfile--;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
	}
#else
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		return;
	}

	if (input->IsKeyPressed(SGD::Key::RightArrow) || input->IsDPadPressed(0, SGD::DPad::Right))
	{
		if (currentProfile >= 2)
			currentProfile = 0;
		else
			currentProfile++;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsKeyPressed(SGD::Key::LeftArrow) || input->IsDPadPressed(0, SGD::DPad::Left))
	{
		if (currentProfile <= 0)
			currentProfile = 2;
		else
			currentProfile--;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsKeyPressed(SGD::Key::Enter) || input->IsButtonPressed(0, 0))
	{
		state = MyState::Menu;
	}

	if (input->IsKeyPressed(SGD::Key::MouseLeft))
	{
		SGD::Point mouse = input->GetMousePosition();
		if (mouse.IsWithinRectangle(SGD::Rectangle{ current, profileSize }))
		{
			state = MyState::Menu;
			return;
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ next, profileSize }))
		{
			if (currentProfile >= 2)
				currentProfile = 0;
			else
				currentProfile++;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ previous, profileSize }))
		{
			if (currentProfile <= 0)
				currentProfile = 2;
			else
				currentProfile--;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
	}
#endif
}
コード例 #3
0
void OptionsState::Update(float dt)
{
	if (dt <= 0.0)
		return;
	SGD::InputManager * input = SGD::InputManager::GetInstance();
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 2))
	{
		GameData::GetInstance()->SwapState(MainMenuState::GetInstance());
		GameData::GetInstance()->PlayCancel();
	}
	if (menuindex == 0)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Left) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x < 0 || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			bool is = GameData::GetInstance()->GetFont()->IsSpanish();
			GameData::GetInstance()->GetFont()->SetSpanish(!is);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 1)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsDPadPressed(0, SGD::DPad::Left) || input->GetLeftJoystick(0).x < 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetMusicVolume(GameData::GetInstance()->GetMusicVolume() - 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
		else if ((input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetMusicVolume(GameData::GetInstance()->GetMusicVolume() + 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 2)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsDPadPressed(0, SGD::DPad::Left) || input->GetLeftJoystick(0).x < 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetEffectVolume(GameData::GetInstance()->GetEffectVolume() - 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
		else if ((input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetEffectVolume(GameData::GetInstance()->GetEffectVolume() + 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 3)
	{
		if ((input->IsKeyPressed(SGD::Key::Enter) || input->IsKeyPressed(SGD::Key::Left) || input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Left) || input->IsDPadPressed(0, SGD::DPad::Right) || input->IsButtonPressed(0, 1) || input->GetLeftJoystick(0).x < 0 || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->PlaySelectionChange();
			bool is = GameData::GetInstance()->GetWindowed();
			GameData::GetInstance()->SetWindowed(!is);
			SGD::GraphicsManager::GetInstance()->Resize({ GameData::GetInstance()->GetScreenWidth(), GameData::GetInstance()->GetScreenHeight() }, GameData::GetInstance()->GetWindowed());
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 4)
	{
		if (input->IsKeyPressed(SGD::Key::Enter) || input->IsButtonPressed(0,1))
		{
			GameData::GetInstance()->PlayCancel();
			GameData::GetInstance()->SwapState(MainMenuState::GetInstance());
			
		}
		
	}







	if ((input->IsKeyPressed(SGD::Key::Up) || input->IsDPadPressed(0, SGD::DPad::Up) || input->GetLeftJoystick(0).y < 0) && GameData::GetInstance()->input_timer < 0)
	{
		menuindex--;
		if (menuindex < 0)
			menuindex = maxindex;
		GameData::GetInstance()->PlaySelectionChange();
		GameData::GetInstance()->input_timer = 0.15f;
	}
	if ((input->IsKeyPressed(SGD::Key::Down) || input->IsDPadPressed(0, SGD::DPad::Down) || input->GetLeftJoystick(0).y > 0) && GameData::GetInstance()->input_timer < 0)
	{
		menuindex++;
		if (menuindex > maxindex)
			menuindex = 0;
		GameData::GetInstance()->PlaySelectionChange();
		GameData::GetInstance()->input_timer = 0.15f;
	}
}