Esempio n. 1
0
void GameInst::Stop()
{
    m_Running = false;
    UnloadLevel();

    //disable user input to the player
    m_pPlayer->SetInputHandler(NULL);
}
Esempio n. 2
0
void GameInst::Update(float a_dt)
{
	if(m_Running)
	{
		//update physworld
		/*m_tLeftPhysUpdate -= a_dt;
		if(m_tLeftPhysUpdate < 0)
		{
			m_tLeftPhysUpdate = PHYS_UPDATE_INTERVAL;
		}*/
		cpSpaceStep(m_pSpace, a_dt);

		//update player
		if(m_pCursor)
		{
			m_pPlayer->SetRedirectDir( VectorNormalise(m_pCursor->GetPosition() - m_pPlayer->GetPosition()) );
		}
		m_pPlayer->Update(a_dt);

		//update emitters (emitters update their individual laser chains)
		for (auto it = Emitters.begin(); it != Emitters.end();++it)
		{
			(*it)->Update(a_dt);
			(*it)->ParseCatchers(catcherPositions);
			
			if ((*it)->GetWon()) {
				if (!m_won) {
					m_winImage->SetPosition(sf::Vector2f(512-(float)m_winImageSource.getSize().x/2,386-(float)m_winImageSource.getSize().y/2));
					m_GUIMgr.AddWidget(m_winImage);
					//Widgets.push_back(winText);
					m_won = true;
				} else {
					m_winTimer += a_dt;
					if (m_winTimer > 3.0f) {
						m_winImage->SetPosition(sf::Vector2f(2048,2048));
						m_GUIMgr.RemoveWidget(m_winImage);
						m_won = false;
						m_winTimer = 0.0f;
						UnloadLevel();
						LoadLevel();
						return;
					}
				}
			}
		}
		
		//update blocks
		for (auto it = m_blocks.begin(); it != m_blocks.end();++it)
		{
			(*it)->Update(a_dt);
		}
	}
}