Ejemplo n.º 1
0
// Input
/*virtual*/ bool PauseState::Input(void)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();


	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsButtonPressed(0, 2) == true)
	{
		SGD::Event msg("UNPAUSE");
		msg.SendEventNow();
		Game::GetInstance()->RemoveState();

		return true;
	}


	if (pInput->IsKeyPressed(SGD::Key::Down) == true || pInput->IsDPadPressed(0, SGD::DPad::Down) == true)
		m_nCursor = m_nCursor + 1 < NUM_CHOICES ? m_nCursor + 1 : 0;
	else if (pInput->IsKeyPressed(SGD::Key::Up) == true || pInput->IsDPadPressed(0, SGD::DPad::Up) == true)
		m_nCursor = m_nCursor - 1 >= 0 ? m_nCursor - 1 : NUM_CHOICES - 1;


	if (pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonDown(0, 1) == true)
	{

		switch (m_nCursor)
		{
		case 0: // gameplay
		{
					SGD::Event msg("UNPAUSE");
					msg.SendEventNow();
					Game::GetInstance()->RemoveState();

					return true;
		}
			break;

		case 1: // controls
		{
					Game::GetInstance()->AddState(HowToPlayState::GetInstance());
					return true;
		}
			break;
		case 2: // options
			
		{
					//Game::GetInstance()->RemoveState();
					//Game::GetInstance()->RemoveState();
					//Game::GetInstance()->AddState(GameplayState::GetInstance());
					Game::GetInstance()->AddState(OptionsState::GetInstance());
					return true;
		}
			break;
		case 3: // main menu
		{
					if (HTPGameState::GetInstance()->GetChoiceScreen() == true)
					{
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->AddState(MainMenuState::GetInstance());
						return true;
					}

					else
					{
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->AddState(IntroState::GetInstance());
						return true;
					}
		}
			break;
		}
	}


	return true;	// keep playing
}
Ejemplo n.º 2
0
// Input
/*virtual*/ bool CreditsState::Input( void )
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();


	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonDown(0, 2) == true)
	{
		Game::GetInstance()->RemoveState();
		//Game::GetInstance()->AddState(MainMenuState::GetInstance());
	}


	return true;
}
Ejemplo n.º 3
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;
}