Esempio n. 1
0
int GAppBase::Loop()
{
	int res;
	double fTime = Timer::Get();
	double fLastTime = fTime;

	while (!m_bQuit)
	{
		fLastTime = fTime;
		fTime = Timer::Get();
		float dt = (float)(fTime - fLastTime);
		dt = std::min<float>(dt, 0.1f);

		if (!m_bPause)
		{
			res = Update(dt * m_fSlomo);
			if (res != 0)
				return res;
		}
		else
		{
			res = UpdatePause();
			if (res != 0)
				return res;
		}

		if (!m_bNoClearScreen)
			m_pEngine->Clear();

		res = Draw();
		if (res != 0)
			return res;

		m_pEngine->ClampClear();
		m_pEngine->Print(m_pEngine->GetWidth() - 5, 5, m_pEngine->GetPrintFont(), 12, RightTop, 255, 255, 255, "%.2f ms / %.2f fps", dt * 1000.f, (dt > 0.f ? 1.f / dt : 0.f));
		m_pEngine->Print(m_pEngine->GetWidth() - 5, 20, m_pEngine->GetPrintFont(), 12, RightTop, 255, 255, 255, "%.2f", fTime);
		m_pEngine->Print(m_pEngine->GetWidth() - 5, 35, m_pEngine->GetPrintFont(), 12, RightTop, 255, 255, 255, "%d %d", m_pEngine->GetMouseX(), m_pEngine->GetMouseY());

		if (m_bPause)
		{
			m_pEngine->ClampClear();
			m_pEngine->CanvasBase::Print(m_pEngine->GetWidth()/2, 100, m_pEngine->GetPrintFont(), 50, Center, (int)(std::sin(fTime*4.f)*0.5f * 254.f) + 127, 0, 0, "PAUSE");
		}

		m_pEngine->Flip();

		m_pEngine->UpdateEvent(dt);
	}

	return 0;
}
Esempio n. 2
0
void GameApp::Update(float timestep){
	button_movement_counter += timestep;
	audio->update(timestep);
	switch (state){
	case MAIN_MENU:
		UpdateMainMenu(timestep);
		break;
	case GAMEPLAY:
		UpdateGamePlay(timestep);
		break;
	case GAME_OVER:
		UpdateGameOver(timestep);
		break;
	case PAUSE:
		UpdatePause(timestep);
		break;
	}
}
Esempio n. 3
0
void EventLevel(void)
{
	// Check for any collision and handle the results
	DetectPlayerCollision();
	// Handle any input for the current player
	InputPlayer(&CurrentPlayer);

	if(FoxInput_KeyTriggered('U'))
	{
		SetDebugMode();
	}
	if(FoxInput_KeyTriggered('I'))
	{
		RemoveDebugMode();
	}
	if(FoxInput_KeyTriggered(VK_ESCAPE))
	{
		InitializePause(&DrawLevel);
		//TogglePauseSound(&BackgroundSnd);
		UpdatePause();
		//TogglePauseSound(&BackgroundSnd);
	}
}
Esempio n. 4
0
void FSoundSource::SetPauseManually(bool bInIsPauseManually)
{
	bIsManuallyPaused = bInIsPauseManually;
	UpdatePause();
}
Esempio n. 5
0
void FSoundSource::SetPauseByGame(bool bInIsPauseByGame)
{
	bIsPausedByGame = bInIsPauseByGame;
	UpdatePause();
}