示例#1
0
void AS_Game::Run() {
	Game::Instance().Run();

	if (Game::Instance().IsEndGame()){
		if (Game::Instance().IsGameOver())
			SetWantedState(EAppState::AS_END_GAME_OVER);
		else if (Game::Instance().IsYouWin())
			SetWantedState(EAppState::AS_END_YOU_WIN);
	}
}
示例#2
0
void AS_Load::Run() {
	String fileContent = String::Read(m_name);
	Array<String> params = fileContent.Split("\n");
	if (params.Size() == EXPECTED_PARAMS_SIZE) {
		Game::Instance().SetLevelInfo(params);
		SetWantedState(AS_PLAYING);
	}
	else 
		SetWantedState(AS_START_MENU);
}
示例#3
0
void AS_Menu::ProcessInput() {
	if (m_processKey) {
		if (Screen::Instance().KeyPressed(GLFW_KEY_ENTER)) {
			SetLastProcessedkey(GLFW_KEY_ENTER);
			m_processKey = false;
			if (m_option != 3) {
				switch (m_option) {
				case 0:
					SetWantedState(EAppState::AS_LOAD_EASY);
					break;
				case 2: 
					SetWantedState(EAppState::AS_LOAD_HARD);
					break; 
				case 1: 
				default:
					SetWantedState(EAppState::AS_LOAD_MEDIUM);
					break;
				}
			}
			else 
				this->SetQuit(true);
		}		
		else if (Screen::Instance().KeyPressed(GLFW_KEY_ESC)) {
			SetLastProcessedkey(GLFW_KEY_ESC);
			m_processKey = false;
			this->SetQuit(true); 
		}
		else if (Screen::Instance().KeyPressed(GLFW_KEY_UP)) {
			SetLastProcessedkey(GLFW_KEY_UP);
			m_processKey = false;
			if (m_option > 0)
				m_option--;
			else 
				m_option = 3; 
		}
		else if (Screen::Instance().KeyPressed(GLFW_KEY_DOWN)) {
			SetLastProcessedkey(GLFW_KEY_DOWN);
			m_processKey = false;
			if (m_option < 3)
				m_option++;
			else
				m_option = 0;
		}
	}
	else {
		if (Screen::Instance().KeyReleased(GetLastProcessedkey()))
			m_processKey = true; 
	}
}
示例#4
0
void AS_Game::ProcessInput() {
	if (m_processKey) {
		if (Screen::Instance().KeyPressed(GLFW_KEY_ENTER)) {
			SetLastProcessedkey(GLFW_KEY_ENTER);
			m_processKey = false;
			SetWantedState(EAppState::AS_PAUSE);
		}
		else if (Screen::Instance().KeyPressed(GLFW_KEY_ESC)) {
			SetLastProcessedkey(GLFW_KEY_ESC);
			m_processKey = false;
			SetWantedState(EAppState::AS_START_MENU);
		}
		else 
			Game::Instance().ProcessInput(); 
	}
	else {
		if (Screen::Instance().KeyReleased(GetLastProcessedkey()))
			m_processKey = true;
	}
}
示例#5
0
void vSoundStreamProperties::Synchronize(const vRenderable *object)
{
    if(!object)
        return;

    const cSoundStream *stream = dynamic_cast<const cSoundStream*>(object);
    if(!stream)
        return;

    // Update properties
    SetVolume(stream->GetVolume());
    SetEnabled(stream->GetEnabled());
    SetLooping(stream->GetLooping());
    SetWantedState(stream->GetWantedState());
    SetFrequency(stream->GetFrequency());
    SetFormat(stream->GetFormat());
    
    // Rewrite chunks queue
    ClearQueue();
    for(std::list<FixedArray<char>*>::const_iterator it = stream->GetDataQueue().begin(); it != stream->GetDataQueue().end(); ++it)
    {
        PushQueue(*it);
    }
};