Beispiel #1
0
int main(int argc,
		 char** pp_argv)
{
	// TODO: http://blog.kalmbachnet.de/?postid=75 beachten (StackWalker-Homepage: http://stackwalker.codeplex.com/releases/view/35258)

#ifdef _DEBUG
	return runTheGame(argc, pp_argv);
#else
	__try
	{
		return runTheGame(argc, pp_argv);
	}
	__except(expFilter(GetExceptionInformation(), GetExceptionCode()))
	{
		return 1;
	}
#endif
}
void StateMachine::run() {
	ResourceManager& resourceManager = ResourceManager::getInstance();
	if (!resourceManager.noUsableScreenResolution) {
		state = loading; //Edit this to set the startup state
	}
	else {
		state = noScreenResolution; //Edit this to set the startup state
	}
	sf::Sound sound;
	while (state != quit) {
		switch (state) {
		case loading:
			state = runLoading();
			break;
		case mainMenu:
			sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState"));
			sound.Play();
			state = runMainMenu();
			break;
		case gameSetup:
			sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState"));
			sound.Play();
			state = runGameSetup();
			break;
		case runGame:
			state = runTheGame();			
			break;
		case gameDone:
			state = runGameDone();
			break;
		case highScore:
			sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState"));
			sound.Play();
			state = runHighScore();
			break;
		case credits:
			sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState"));
			sound.Play();
			state = runCredits();
			break;
		case help:
			sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState"));
			sound.Play();
			state = runHelp();
			break;
		case noScreenResolution:
			state = runNoScreenResolution();
			state = quit;
			break;
		case tournament:
			state = runTournament();
		default:
			break;
		}
		// Just in case something in the list is bad pointers.
		// TODO: Clean up all resources in the end of all
		// state functions (like runTheGame)
		resourceManager.drawableList.clear();
	}
	resourceManager.win.Close();
}