void DynamicStimulusDriver::unpause() {
    boost::mutex::scoped_lock locker(stim_lock);
    
    if (isPlaying() && isPaused()) {
        endPause();
    }
}
Exemple #2
0
/*
	Name:	checkPause
	Desc:	checks to see if the game must be paused or unpaused
	Args:	None
	Rtrn:	None
*/
void Game::checkPause()
{
	bool pauseKeyDownThisFrame = sf::Keyboard::isKeyPressed(sf::Keyboard::P);

	if(!m_pausedKeyDown && pauseKeyDownThisFrame)
	{
		if(!m_paused)
		{
			beginPause();
		}
		else
		{
			endPause();
		}
	}
	m_pausedKeyDown = pauseKeyDownThisFrame;
}
Exemple #3
0
void BlobGame::changeState(const BlobGameStates& state){
	switch(m_CurrentState){
	case MainMenu:
		endMainMenu();
		break;
	case OptionsMenu:
		endOptions();
		break;
	case PauseMenu:
		endPause();
		break;
	case Editor:
		endEditor();
		break;
	case LevelSelect:
		endLevelSelect();
		break;
	}
	switch(state){
	case MainMenu:
		beginMainMenu();
		blobUpdate = &BlobGame::mainMenu;
		break;
	case GamePlay:
		beginGame();
		blobUpdate = &BlobGame::gamePlay;
		break;
	case OptionsMenu:
		beginOptions();
		blobUpdate = &BlobGame::optionsMenu;
		break;
	case PauseMenu:
		beginPause();
		blobUpdate = &BlobGame::pauseMenu;
		break;
	case Editor:
		beginEditor();
		blobUpdate = &BlobGame::editor;
		break;
	case LevelSelect:
		beginLevelSelect();
		blobUpdate = &BlobGame::levelSelect;
		break;
	}
	m_CurrentState = state;
}
Exemple #4
0
/*
	Name:	handleEvents
	Desc:	handles all the window events and the events related to the paused and end game screens
	Args:	None
	Rtrn:	None
*/
void Game::handleEvents()
{
	sf::Event event;
	while (m_window->pollEvent(event))
	{
		if(event.type == sf::Event::Closed)
			m_window->close();

		//In game mouse events.
		if(!m_paused && !m_gameOver)
		{
			if(event.type == sf::Event::MouseMoved)
			{
				m_player.setPosition(event.mouseMove.x, event.mouseMove.y);
				m_player.getParticleSys().moveEmitter(sf::Vector2f(event.mouseMove.x, event.mouseMove.y));
				//Distance formulae
				int points = sqrt((event.mouseMove.x - m_player.getLastPos().x) * (event.mouseMove.x - m_player.getLastPos().x))
					+	sqrt((event.mouseMove.y - m_player.getLastPos().y) * (event.mouseMove.y - m_player.getLastPos().y));
				m_player.addPoints(points);
				m_player.setLastPosition(sf::Vector2f(event.mouseMove.x, event.mouseMove.y));
			}

			if(event.type == sf::Event::LostFocus)
				beginPause();
			//Feature not implemented due to unforseen problems. Related to pausing the game when the mouse leaves the 
			//window area.
			/*
			if(!sf::IntRect(sf::Vector2i(m_window->getPosition()),
				sf::Vector2i(m_window->getSize())).contains(sf::Mouse::getPosition()))
			{
				BeginPause();
			}
			*/
		}

		//In paused mouse events.
		else if(m_paused && !m_gameOver)
		{
			if(event.type == sf::Event::MouseMoved)
			{
				//Buttons
				if(m_pauseCont.getSprite().getGlobalBounds().contains(event.mouseMove.x, event.mouseMove.y))
					m_pauseCont.startHover();
				else
					m_pauseCont.endHover();

				if(m_pauseQuit.getSprite().getGlobalBounds().contains(event.mouseMove.x, event.mouseMove.y))
					m_pauseQuit.startHover();
				else
					m_pauseQuit.endHover();
			}

			if(event.type == sf::Event::MouseButtonPressed)
			{
				if(event.mouseButton.button == sf::Mouse::Left)
				{
					//Continue
					if(m_pauseCont.getSprite().getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
					{
						endPause();
					}
					//Quit
					if(m_pauseQuit.getSprite().getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
					{
						forceQuit();
					}
				}
			}
		}

		//Game over
		else
		{
			if(event.type == sf::Event::MouseMoved)
			{
				//Buttons
				if(m_endRetry.getSprite().getGlobalBounds().contains(event.mouseMove.x, event.mouseMove.y))
					m_endRetry.startHover();
				else
					m_endRetry.endHover();

				if(m_endQuit.getSprite().getGlobalBounds().contains(event.mouseMove.x, event.mouseMove.y))
					m_endQuit.startHover();
				else
					m_endQuit.endHover();
			}

			if(event.type == sf::Event::MouseButtonPressed)
			{
				if(event.mouseButton.button == sf::Mouse::Left)
				{
					//Continue
					if(m_endRetry.getSprite().getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
					{
						m_retry = true;
						forceQuit();
					}
					//Quit
					if(m_endQuit.getSprite().getGlobalBounds().contains(event.mouseButton.x, event.mouseButton.y))
					{
						forceQuit();
					}
				}
			}
		}
	}
}