Exemplo n.º 1
0
//Holds game logic together
int Game::OnStart() {
	//Initialize the game
	if (OnInit() == false) {
        return -1;
    }

	SDL_Event Event;

	//While game is running 
	while (running) {
		while (gameType == 0 && running) {
			while (SDL_PollEvent(&Event)) {
				OnEvent(&Event);
			}
			//meanwhile show menu
			showMenu();
		}
		while (SDL_PollEvent(&Event)) {
			//Handle user input
			OnEvent(&Event);
		}
		OnLoop();
		OnRender();
	}
 
    OnCleanUp();
 
    return 0;
};
Exemplo n.º 2
0
void Engine::Run()
{
	OnInit();
	m_isRunning = true;
	while (m_isRunning)
	{
		OnRender();
		OnUpdate(1.0f);
	}
	OnCleanUp();
}
Exemplo n.º 3
0
int Application::OnExecute() {
	std::string finalMessage;
	
	try {
		Timer fpsManager;

		OnInit();
		
		while (isRunning) {
			fpsManager.Start();

			while (SDL_PollEvent(&eventHandled)) {
				OnEvent(&eventHandled);
			}
			
			OnLoop();
			OnRender();

			fpsManager.FrameRate();
		}
		
		OnCleanUp();
	} catch (const SDLException& sdlException) {
		finalMessage.append("<SDL Error>");
		finalMessage.append(" => ");
		finalMessage.append(sdlException.WhatHappens());

		Logger::WriteMessageInLogFile(finalMessage.c_str());
		return -1;
	} catch (const TTFException& ttfException) {
		finalMessage.append("<TTF Error>");
		finalMessage.append(" => ");
		finalMessage.append(ttfException.WhatHappens());

		Logger::WriteMessageInLogFile(finalMessage.c_str());
		return -1;
	} catch (const MixerException& mixerException) {
		finalMessage.append("<Mixer Error>");
		finalMessage.append(" => ");
		finalMessage.append(mixerException.WhatHappens());

		Logger::WriteMessageInLogFile(finalMessage.c_str());
		return -1;
	} catch (const GenericException& exception) {
		Logger::WriteMessageInLogFile(exception.WhatHappens());
		return -1;
	}
	
	return 0;
}
Exemplo n.º 4
0
		int Frontend::OnExecute()
		{
			if (OnInit() == false) return -1;

			SDL_Event event;

			std::cout << "Execution started.\n";
			while (Running == true)
			{
				while (SDL_PollEvent(&event))
				{
					OnEvent(&event);
				}

				OnLoop();
				OnRender();
			}
		
			OnCleanUp();

			return 0;
		}
Exemplo n.º 5
0
XLSocket::~XLSocket(void)
{
	OnCleanUp();
}
Exemplo n.º 6
0
void XLSocket::Stop()
{
	OnCleanUp();
}