コード例 #1
0
ファイル: Game.cpp プロジェクト: CaterHatterPillar/PACMANIA
void Game::update(double delta)
{
	Msg* msg = peek();
	while(msg)
	{
		msg = pop();
		if(msg)
		{
			MsgType type = msg->Type();
			switch(type)
			{
			case ENTITY_GHOST_SPAWN:
				msgSpawnGhost(msg);
				break;
			case INPUT_KEYBOARD_MSG:
				msgKeyboard(msg);
				break;
			case GAME_OVER:
				msgGameOver(msg);
				break;
			case GAME_WON:
				msgGameWon(msg);
				break;
			default:
				throw 0; //temp
				break;
			}
		}
	}
}
コード例 #2
0
//! application logic
void ActiveState::Logic (void)
{
	CliApp::Instance()->Logger() << ends << LOG_DEBUG
		<< "Active state logic" << endl;

	CliApp::Instance()->Logger() << ends << LOG_INFO 
		<< "Continuing" << endl;

	//! send a keepalive message to the server
	CliApp::Instance()->Server()->Send(*m_poContinueMsg);
	try 
	{
		//! try to get a response from the server
		Msg oRecvMsg = CliApp::Instance()->Server()->Recv();

		//! if the server does not respond positively
		if (oRecvMsg.Type() != CONTINUING )
		{
			//! the application should change state to connecting
			CliApp::Instance()->Logger() << ends << LOG_INFO 
				<< "ACTIVE => CONN" << endl;
			CliApp::Instance()->StateTrans(CONN);
		}
		else
		{
			//! otherwise, we're still active
			CliApp::Instance()->Logger() << ends << LOG_INFO
				<< "ACTIVE" << endl;
			//! sleep for some time before the next keepalive
			sleep(m_i32PollInterval);
		}
	} 
	catch (TimeoutException& roExc) 
	{ 
		//! if the server does not respond for some time
		CliApp::Instance()->Logger() << ends << LOG_DEBUG
			<< "Timeout in continue" << endl;
	}
	catch (SyscallException& roExc)
	{
		//! if we are interrupted before the server can respond
		CliApp::Instance()->Logger() << ends << LOG_CRIT
			<< "Syscall failed in ACTIVE: "
			<< roExc.what() << endl;
		CliApp::Instance()->StateTrans(ERROR);
	}
}