Esempio n. 1
0
void BattleGroundAV::Update(uint32 diff)
{
    BattleGround::Update(diff);

    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    // add points from mine owning, and look if the neutral team can reclaim the mine
    for (uint8 mine = 0; mine < BG_AV_MAX_MINES; ++mine)
    {
        if (m_Mine_Owner[mine] != BG_AV_TEAM_NEUTRAL)
        {
            m_Mine_Timer[mine] -= diff;
            if (m_Mine_Timer[mine] <= 0)
            {
                UpdateScore(BattleGroundTeamIndex(m_Mine_Owner[mine]), WORLD_STATE_ADD);
                m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER;
            }

            if (m_Mine_Reclaim_Timer[mine] > diff)
                m_Mine_Reclaim_Timer[mine] -= diff;
            else
                ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL);
        }
    }

    // looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team
    for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
    {
        if (m_Nodes[i].State == POINT_ASSAULTED)
        {
            if (m_Nodes[i].Timer > diff)
                m_Nodes[i].Timer -= diff;
            else
                EventPlayerDestroyedPoint(i);
        }
    }
}
/* ================================================ */
void PartsCounter::UpdateParts()
{
	int32_t diff = m_value-m_currDispValue;

	if( m_currDispValue == m_value ){
		// 更新がなければ何もしない
		return;
	}
	else if( m_isInvalidCountAnim || math::Abs(diff) < 30 ){
		m_currDispValue = m_value;
	}
	else{
		if( m_counter%10 == 0 ){	
			// カウントSE鳴らす
			SoundManager::GetInstance()->PlaySE("Count", 8500);
		}
		++m_counter;

		m_currDispValue += static_cast<int32_t>(diff*0.05);
	}

	// 表示更新
	UpdateScore( m_currDispValue );
}
Esempio n. 3
0
/*
=============================
idGameBearShootWindow::UpdateGame
=============================
*/
void idGameBearShootWindow::UpdateGame() {
	int i;

	if ( onNewGame ) {
		ResetGameState();
		if ( goal ) {
			goal->position.x = 550;
			goal->position.y = 164;
			goal->velocity.Zero();
		}
		if ( helicopter ) {
			helicopter->position.x = 550;
			helicopter->position.y = 100;
			helicopter->velocity.Zero();
		}
		if ( bear ) {
			bear->SetVisible( false );
		}

		bearTurretAngle.SetFloat( 0.f );
		bearTurretForce.SetFloat( 200.f );

		gamerunning = true;
	}
	if ( onContinue ) {
		gameOver = false;
		timeRemaining = 60.f;

		onContinue = false;
	}

	if(gamerunning == true) {
		int current_time = gui->GetTime();
		idRandom rnd( current_time );

		// Check for button presses
		UpdateButtons();

		if ( bear ) {
			UpdateBear();
		}
		if ( helicopter && goal ) {
			UpdateHelicopter();
		}

		// Update Wind
		if ( windUpdateTime < current_time ) {
			float	scale;
			int		width;

			windForce = rnd.CRandomFloat() * ( MAX_WINDFORCE * 0.75f );
			if (windForce > 0) {
				windForce += ( MAX_WINDFORCE * 0.25f );
				wind->rotation = 0;
			} else {
				windForce -= ( MAX_WINDFORCE * 0.25f );
				wind->rotation = 180;
			}

			scale = 1.f - (( MAX_WINDFORCE - idMath::Fabs(windForce) ) / MAX_WINDFORCE);
			width = 100*scale;

			if ( windForce < 0 ) {
				wind->position.x = 500 - width + 1;
			} else {
				wind->position.x = 500;
			}
			wind->SetSize( width, 40 );

			windUpdateTime = current_time + 7000 + rnd.RandomInt(5000);
		}

		// Update turret rotation angle
		if ( turret ) {
			turretAngle = bearTurretAngle.GetFloat();
			turret->rotation = turretAngle;
		}

		for( i = 0; i < entities.Num(); i++ ) {
			entities[i]->Update( timeSlice );
		}

		// Update countdown timer
		timeRemaining -= timeSlice;
		timeRemaining = idMath::ClampFloat( 0.f, 99999.f, timeRemaining );
		gui->SetStateString( "time_remaining", va("%2.1f", timeRemaining ) );

		if ( timeRemaining <= 0.f && !gameOver ) {
			gameOver = true;
			updateScore = true;
		}

		if ( updateScore ) {
			UpdateScore();
			updateScore = false;
		}
	}
}
Esempio n. 4
0
void BattleGroundAV::Update(uint32 diff)
{
    BattleGround::Update(diff);

    if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
    {
        ModifyStartDelayTime(diff);

        if (!(m_Events & 0x01))
        {
            m_Events |= 0x01;

            if(!SetupBattleGround())
            {
                EndNow();
                return;
            }

            sLog.outDebug("Alterac Valley: entering state STATUS_WAIT_JOIN ...");
            SetStartDelayTime(START_DELAY0);
        }
        // After 1 minute, warning is signalled
        else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04))
        {
            m_Events |= 0x04;
            SendMessageToAll(GetMangosString(LANG_BG_AV_START_ONE_MINUTE));
        }
        // After 1,5 minute, warning is signalled
        else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08))
        {
            m_Events |= 0x08;
            SendMessageToAll(GetMangosString(LANG_BG_AV_START_HALF_MINUTE));
        }
        // After 2 minutes, gates OPEN ! x)
        else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10))
        {
            UpdateWorldState(BG_AV_SHOW_H_SCORE, 1);
            UpdateWorldState(BG_AV_SHOW_A_SCORE, 1);

            m_Events |= 0x10;

            SendMessageToAll(GetMangosString(LANG_BG_AV_HAS_BEGUN));
            PlaySoundToAll(SOUND_BG_START);
            SetStatus(STATUS_IN_PROGRESS);

            OpenDoorEvent(BG_EVENT_DOOR);

            for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
                if(Player* plr = sObjectMgr.GetPlayer(itr->first))
                    plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
        }
    }


    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    // add points from mine owning, and look if the neutral team can reclaim the mine
    for(uint8 mine = 0; mine < BG_AV_MAX_MINES; mine++)
    {
        if (m_Mine_Owner[mine] == BG_TEAM_ALLIANCE || m_Mine_Owner[mine] == BG_TEAM_HORDE)
        {
            m_Mine_Timer[mine] -=diff;
            if (m_Mine_Timer[mine] <= 0)
            {
                UpdateScore(BattleGroundTeamId(m_Mine_Owner[mine]), 1);
                m_Mine_Timer[mine] = BG_AV_MINE_TICK_TIMER;
            }

            if (m_Mine_Reclaim_Timer[mine] > diff)
                m_Mine_Reclaim_Timer[mine] -= diff;
            else
                ChangeMineOwner(mine, BG_AV_NEUTRAL_TEAM);
        }
    }

    // looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team
    for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
    {
        if (m_Nodes[i].State == POINT_ASSAULTED)
        {
            if (m_Nodes[i].Timer > diff)
                m_Nodes[i].Timer -= diff;
            else
                 EventPlayerDestroyedPoint(i);
        }
    }
}
Esempio n. 5
0
// on "init" you need to initialize your instance
bool Game::init() {
    if ( !LayerColor::init()) {//initWithColor(Color4B(255, 0, 0, 255)) ) {
        return false;
    }
    
    // add background music
    CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("action.mp3", true);
    
    // enable touch events
    setTouchEnabled(true);
    
    // get screen size
    Size screenSize = Director::getInstance()->getVisibleSize();

    // add menu button
    MenuItemLabel* menuItem = MainMenu::createButton("End Game", CC_CALLBACK_1(Game::menuCallback, this));
	menuItem->setPosition(Point(screenSize.width - menuItem->getContentSize().width/2 - Letter::PADDING,
                                menuItem->getContentSize().height/2 + Letter::PADDING));
    // create menu, it's an autorelease object
    auto menu = Menu::create(menuItem, NULL);
    menu->setPosition(Point::ZERO);
    this->addChild(menu, 1);
    
    // display score on the screen
    scoreLabel = LabelTTF::create("Score: 0", "Arial", 35);
    scoreLabel->setColor(Color3B(255, 255, 255));
    scoreLabel->setPosition(Point(Letter::PADDING + scoreLabel->getContentSize().width/2, screenSize.height-scoreLabel->getContentSize().height/2 - Letter::PADDING));
    this->addChild(scoreLabel, 1);
    
    // display moves on the screen
    movesLabel = LabelTTF::create("Moves: 20", "Arial", 35);
    movesLabel->setColor(Color3B(255, 255, 255));
    movesLabel->setPosition(Point(screenSize.width - movesLabel->getContentSize().width/2 - Letter::PADDING, screenSize.height - movesLabel->getContentSize().height/2 - Letter::PADDING));
    this->addChild(movesLabel, 1);
    
    // set number of moves
    moves = STARTING_MOVES;
    
    // create board
    Board board = Board(this);
    // whether a letter has been selected
    bool letterSelected = false;
    
    auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
    listener->setSwallowTouches(false);
    listener->onTouchBegan = [=](Touch* touch, Event* event) mutable {
        //log("touch began");
        Point location = touch->getLocation();//->getLocationInView();
        // TODO: Detect touches on labels
        for (int i = 0; i < Board::BOARD_SIZE; i++) {
            vector<Letter> row = board.letters[i];
            for (int j = 0; j < Board::BOARD_SIZE; j++) {
                Letter l = row[j];
                if (location.getDistance(l.posn) < 30) {
                    //log("touched %c", l.letter);
                    
                    l.label->setColor(cocos2d::Color3B(0, 255, 0));
                    
                    //cocos2d::log("letter selected %s, %c", letterSelected ? "true" : "false", board.selected.letter);
                    if (!letterSelected) {
                        // first letter selected
                        board.selected = l;
                        letterSelected = true;
                        //cocos2d::log("set selected to %c, %s", board.selected.letter, letterSelected ? "true" : "false");
                    } else if (board.selected != l) {
                        // second selected letter is not the same as first
                        board.letterSwap(l);
                        letterSelected = false;
                        UpdateScore();
                        UpdateMoves();
                    } else {
                        // same letter was selected
                        //cocos2d::log("you selected the same letter %c", board.selected.letter);
                        // set letterSelected to false
                        letterSelected = false;
                        // reset selected color
                        board.selected.label->setColor(cocos2d::Color3B(255, 255, 255));
                        // set selected letter to empty Letter
                        board.selected = Letter();
                    }
                    
                    return true;
                }
            }
        }
        return false;
    };
    
    // unused listeners
    //listener->onTouchMoved = [](Touch* touch, Event* event) { log("touch moved"); };
    //listener->onTouchEnded = [](Touch* touch, Event* event) { log("touch ended"); };
    //listener->onTouchCancelled = [](Touch* touch, Event* event) { log("touch canceled"); };
    
    // The priority of the touch listener is based on the draw order of sprite
    //EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite);
    // Or the priority of the touch listener is a fixed value
    EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100);
    
    return true;
}
Esempio n. 6
0
bool PlayGame(Map &map, ResourceManager &resourceManager, const unsigned int livesIn)
{
    bool nextMap(true), menu(true);

    SoundPlayer soundPlayer(alcGetCurrentContext());

    unsigned int lives(livesIn);
    unsigned int specialItemScoreRequired(1000);
    unsigned int score(0), changedScore(score);
    TextRenderer textRender(resourceManager.GetTexture("text.png"));

    std::vector<std::string> stringVec{"Score:", "0"};
    std::vector<std::string> livesVec{"Lives: ", std::to_string(lives)};

    textRender.AddTextVerticalAlign(stringVec, TextRenderer::Alignment::Right, TextRenderer::Alignment::Top, 20.0f);
    textRender.AddTextHorizontalAlign(livesVec, TextRenderer::Alignment::Right, TextRenderer::Alignment::Bottom, 20.0f);

    glm::mat4 view(glm::ortho(0.0f, 40.0f, 0.0f, 30.0f, 1.0f, -1.0f));
    std::vector<std::shared_ptr<VisibleObject>> objectVec;
    std::vector<Movement> movementVec;
    std::vector<std::shared_ptr<AI>> aiVec;
    std::vector<float> aiStateSwitchTimes;
    std::vector<DeadPlayers> deadPlayerVec;

    int level(0);
    int timesToChange(7);

    while(nextMap && !glfwWindowShouldClose(glfwGetCurrentContext()))
    {
        ++level;
        timesToChange = UpdateAiSwitchVec(aiStateSwitchTimes, timesToChange, level);
        bool playing = true;
        map.LoadNextMap();

        GetVecFullOfObjects(objectVec, map, resourceManager, aiVec);
        textRender.AddTextHorizontalAlign(livesVec, TextRenderer::Alignment::Right, TextRenderer::Alignment::Bottom, 20.0f);

        CollisionDetection collisionDetect;
        collisionDetect.AddPlayersAndEnemys(objectVec);
        map.HideSpecialObj();

        double currTime = glfwGetTime(), prevTime = glfwGetTime(),
                mapStartTime = glfwGetTime(), enemyKillFinish(0.0);

        while(playing && !glfwWindowShouldClose(glfwGetCurrentContext()))
        {

            glClear(GL_COLOR_BUFFER_BIT);

            if(AISwitchModes(aiVec, currTime - mapStartTime, aiStateSwitchTimes.back()))
            {
                soundPlayer.AddToPlay(*(resourceManager.GetSound("wolfhowl.ogg")));
                aiStateSwitchTimes.erase(aiStateSwitchTimes.end() - 1);
            }
            if(score >= specialItemScoreRequired)
                specialItemScoreRequired = UpdateSpecialItem(objectVec, map, specialItemScoreRequired, resourceManager);
            if(enemyKillFinish != 0.0)
            {
                if(currTime >= enemyKillFinish)
                {
                    UpdateEnemysDieStatus(objectVec, resourceManager);
                    enemyKillFinish = 0.0;
                }
            }
            if(!deadPlayerVec.empty())
            {
                for(auto player(deadPlayerVec.begin()); player != deadPlayerVec.end();)
                {
                    if((*player).timeEnemyShouldLive <= currTime)
                    {
                        (*player).player->SwitchDeathVao();
                        (*player).player->ResetToOriginalSquare();
                        player = deadPlayerVec.erase(player);
                    }
                    else
                        ++player;
                }
            }

            if(GetInput(movementVec, aiVec, map))
            {
                if(PauseMenu(resourceManager, menu))
                {
                    playing = false;
                    nextMap = false;
                    break;
                }
                glfwSetTime(currTime);
            }

            for(auto & obj : objectVec)
            {
                if(obj->GetPlayer() > 0)
                {
                    UpdatePlayerMovement(obj, movementVec, map, currTime - prevTime);
                    if(obj->GetPlayer() == 1)
                    {
                        if(UpdateMap(obj, objectVec, map, changedScore, soundPlayer, resourceManager))
                        {
                            if(enemyKillFinish == 0.0f)
                            {
                                enemyKillFinish = currTime;
                                UpdateEnemysDieStatus(objectVec, resourceManager);
                            }
                            currTime -= 5.0;
                            glfwSetTime(currTime);
                        }
                        if(score != changedScore)
                        {
                            UpdateScore(changedScore, textRender, stringVec);
                            score = changedScore;

                            if(map.HasFinished())
                            {
                                playing = false;
                                nextMap = true;
                            }
                        }
                    }
                }
                obj->Draw(view);
            }
            textRender.DrawAll();

            if(collisionDetect.DetectCollisions(lives, changedScore, deadPlayerVec, resourceManager, soundPlayer))
            {
                soundPlayer.AddToPlay(*(resourceManager.GetSound("death.ogg")));
                if(UpdateLives(lives, textRender, livesVec))
                {
                    playing = false;
                    nextMap = false;
                    UpdateHighscore(score, resourceManager);
                }
            }

            glfwSwapBuffers(glfwGetCurrentContext());
            glfwPollEvents();

            prevTime = currTime;
            currTime = glfwGetTime();
        }
    }
    if(glfwWindowShouldClose(glfwGetCurrentContext()))
        nextMap = false;

    return menu;
}
Esempio n. 7
0
void safebag_touch( edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
	static float	last_touch_time;
	static edict_t	*last_touch_ent;
	static int		last_touch_count = 0;

	if (!other->client)
		return;

	if ((level.time < last_touch_time) || (last_touch_time && (last_touch_time < (level.time - 2.0))) || (last_touch_ent && (last_touch_ent != other)))
	{	// reset
		last_touch_time = 0;
		last_touch_ent = NULL;
		last_touch_count = 0;
	}
	else if (last_touch_time > (level.time - 0.1))
	{
		return;
	}
	else
	{
		last_touch_count++;
		last_touch_time = level.time;

		if (last_touch_count > (int)(50.0 * (1.0 + (0.5*(other->client->pers.team == self->style)))))
		{
			// let them go away on their own terms
			T_Damage( other, other, other, vec3_origin, other->s.origin, vec3_origin, 9999, 0, 0, MOD_SAFECAMPER );
			last_touch_count = 0;
		}
	}

	last_touch_ent = other;

	if (other->client->pers.team == self->style)
	{
		if (self->timestamp > (level.time - 0.5))
			return;
	}
	else if (self->timestamp > (level.time - 1.0))
		return;

	self->timestamp = level.time;

	// depositing, or withdrawing?

	if (other->client->pers.team == self->style)
	{	// deposit
		
		if (other->client->pers.currentcash > 0 || other->client->pers.bagcash > 0)
		{
			int	precash, amount;

			precash = team_cash[self->style];

			team_cash[self->style] += other->client->pers.currentcash;
			team_cash[self->style] += other->client->pers.bagcash;
			UpdateScore();

			other->client->resp.deposited += other->client->pers.currentcash;
			other->client->resp.deposited += other->client->pers.bagcash;

			other->client->pers.currentcash = 0;
			other->client->pers.bagcash = 0;

			gi.sound(other, CHAN_ITEM, gi.soundindex("world/pickups/cash.wav"), 1, 3, 0);

			// make a droping sound
			gi.positioned_sound(self->s.origin, self, CHAN_ITEM, gi.soundindex("world/doors/dr1_end.wav"), 1, 1, 0);

			// let everyone know how much was deposited
			amount = team_cash[self->style] - precash;
			gi.bprintf( PRINT_MEDIUM, "%s deposited $%i\n", other->client->pers.netname, amount );
			other->client->fakeThief = 0;

			last_safe_deposit[self->style] = level.time;
		}

	}
	else if (team_cash[self->style] > 0)
	{	// withdrawal

		if (other->client->pers.bagcash < MAX_BAGCASH_PLAYER)
		{
			int	precash, amount;

			precash = team_cash[self->style];

			team_cash[self->style] -= (MAX_BAGCASH_PLAYER - other->client->pers.bagcash);
			other->client->pers.bagcash += (MAX_BAGCASH_PLAYER - other->client->pers.bagcash);

			if (team_cash[self->style] < 0)
			{	// don't take more than they have
				other->client->pers.bagcash += team_cash[self->style];
				team_cash[self->style] = 0;
			}
			UpdateScore();

			gi.sound(other, CHAN_ITEM, gi.soundindex("world/pickups/cash.wav"), 1, 3, 0);

			// alarm!
			gi.positioned_sound(self->s.origin, self, CHAN_ITEM, gi.soundindex("misc/cashmatch_alarm.wav"), 1, 1, 0);

			// let everyone know how much was stolen
			other->client->fakeThief = amount = precash - team_cash[self->style];
			gi.bprintf( PRINT_MEDIUM, "%s stole $%i from %s's safe!\n", other->client->pers.netname, amount, team_names[self->style] );

			last_safe_withdrawal[self->style] = level.time;

			other->client->resp.stole += amount;
		}

	}
}
Esempio n. 8
0
//---------------------------------------------------------------------------- 
// Nome: OnGame(void)
// Desc: Trata o estado GS_GAME
// Pams: nenhum
//---------------------------------------------------------------------------- 
void CLevel::OnGame(void)
{
	if(pr_Main->InputManager.KeyPressed(DIK_ESCAPE))
	{
		ChangeState(GS_MENU);
	}	

	//atualiza os personagens o laço é feito de trás para diante porque caso
	//um ou mais personagens tenham terminado sua execução, eles podem ser
	//excluídos sem dar problema de índices inválidos no vetor.
	int i = 0;
	for(i = (short)ListCharacters.size()-1; i >= 0; i--)
	{
		//executa o personagem
		ListCharacters[i]->Execute();

		//21.1.5.
		//se o personagem morreu e não for o jogador, remover da lista

	}
	
	//atualiza a câmera no jogador se ele não estiver morrendo
	if (!pr_Player->IsDieing())
	{
		LookToPlayer();
	}
	
	//17.5.1. 
	//colocar o jogo em pausa, caso tecla P seja pressionada
	if(pr_Main->InputManager.KeyPressed(DIK_P))
	{
		ChangeState(GS_PAUSE);
	}

	
	//18.2.6. Atualização ou execução dos itens
	//o laço é feito de trás para frente porque caso um ou mais
	//itens tenham terminado sua execução, eles podem ser removidos
	//sem dar problema de índices inválidos no vetor.

	int iSize = (int) ListItems.size();

	for(int i=iSize-1; i >= 0; i--){
		ListItems[i]->Execute();
		if(ListItems[i]->GetState() == CItem::IS_END){
			ListItems[i]->Release();
			delete ListItems[i];
			ListItems.erase(ListItems.begin()+i);
		}
	}

	//23.1.3. 
	//2. se os itens terminaram, preparar programação de fim de jogo.
	if(iSize == 0)
	{
		//a alavanca ainda não foi ativada...
		if(p_SprSwitch->sCurrentAnim == 0)
		{
			//se o jogador colide com a alavanca

		}
		//3. interação do jogador com a moeda	
		else
		{
			//caso o jogador encoste na moeda, mudar estado do jogo

		}
	}

	//se existe a layer de interface...
	if(p_LayInterface)
	{
		//17.2.3. Atualizar o placar
		UpdateScore();
		//17.3.3. Atualizar o número de vidas
		UpdateLives();

	}

	//19.2.3. atualiza os tiros
	//remove aqueles que estão no estado SS_END

}
Esempio n. 9
0
void ScoreboardSurface::AddScore(std::uint32_t points)
{
	m_score += points;
	UpdateScore();
}
Esempio n. 10
0
void CPlayer::Update(CMap* Map)
{
    int TilePos = 0;

    m_VelX = 5;
	m_VelY = 30;

	m_bScoreChanged = false;
	m_bLivesChanged = false;
	m_bCoinsChanged = false;

	m_bTouchesGround = false;

	//x axis first (--)
	if(m_bRight == true)
    {
        if (m_State != "JUMPING")
        {
            m_State = "WALKING_RIGHT";
        }
        else
        {
            m_State = "JUMPING";
        }

		if(Collision_Ver(m_PosX + m_Width + m_VelX, m_PosY, TilePos, Map) == 1)
        {
			m_PosX = (TilePos * Tile.GetSize()) - m_Width;
			Mix_PlayChannel(-1,cBlockhit,0);
        }
        else if (Collision_Ver(m_PosX + m_Width + m_VelX, m_PosY, TilePos, Map) == 2)
        {
            m_PosX = (TilePos * Tile.GetSize()) - m_Width;
            Mix_PlayChannel(-1,cBlockhit,0);
        }
        else if (Collision_Ver(m_PosX + m_Width + m_VelX, m_PosY, TilePos, Map) == 3) //Lava
        {
            m_VelX = 0;
            m_bDead = true;
            m_State = "DYING";
            m_Lives -= 1;
            m_bLivesChanged = true;
        }
        else if (Collision_Ver(m_PosX + m_Width + m_VelX, m_PosY, TilePos, Map) == 5) //Coins
        {
            m_PosX += m_VelX;
            m_Score += 100;
            m_bScoreChanged = true;
			m_Coins += 1;
			m_bCoinsChanged = true;
			Mix_PlayChannel(-1,cCoinCollected,0);

			Map->SetTileAtPos( (int) (m_PosX / 32), (int) (m_PosY / 32),0,0);
        }
		else
        {
            m_PosX += m_VelX;
        }
	}
	else if(m_bLeft)
	{
	    if (m_State != "JUMPING")
        {
            m_State = "WALKING_LEFT";
        }
        else
        {
            m_State = "JUMPING";
        }

		if(Collision_Ver(m_PosX - m_VelX, m_PosY, TilePos, Map) == 1)
        {
            m_PosX = (TilePos + 1)* Tile.GetSize();
            Mix_PlayChannel(-1,cBlockhit,0);
        }
        else if (Collision_Ver(m_PosX - m_VelX, m_PosY, TilePos, Map) == 2)
        {
            m_PosX = (TilePos + 1)* Tile.GetSize();
        }
        else if (Collision_Ver(m_PosX - m_VelX, m_PosY, TilePos, Map) == 3)
        {
            m_VelX = 0;
            m_State = "DYING";
            m_Lives -= 1;
            m_bLivesChanged = true;
        }
        else if (Collision_Ver(m_PosX - m_VelX, m_PosY, TilePos, Map) == 5) //Coins
        {
            m_PosX -= m_VelX;
            m_Score += 100;
            m_bScoreChanged = true;
			m_Coins += 1;
			m_bCoinsChanged = true;
			Mix_PlayChannel(-1,cCoinCollected,0);

			Map->SetTileAtPos( (int) ((m_PosX - m_VelX) / 32), (int) (m_PosY / 32),0,0);
        }
        else if (Collision_Ver(m_PosX, m_PosY, TilePos, Map) == 6) //
        {
            m_PosX = (TilePos + 1)* Tile.GetSize();
        }
		else
        {
            m_PosX -= m_VelX;
        }
	}

	//then y axis (|)
 	if(m_bIsJumping == true) //up
    {
        m_State = "JUMPING";

        Mix_PlayChannel(-1,cJump,0);

		if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 1)
        {
			m_PosY = (TilePos + 1)* Tile.GetSize();
			m_VelY = 0;
			m_bLockJump = true;
			m_bApexReached = true;
			if (m_bApexReached == true)
            {
                m_PosY += m_Gravity;
            }

			Mix_PlayChannel(-1,cBlockhit,0);
		}
		else if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 2)
        {
			m_PosY	-= m_VelY;
		}
		else if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 3)
        {
            m_VelX = 0;
            m_PosY += m_Gravity;
			m_State = "DYING";
            m_Lives -= 1;
            m_bLivesChanged = true;
		}
		else if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 5)
        {
			m_PosY	-= m_VelY;
			m_sScore = "";
			m_Score += 100;
			m_bScoreChanged = true;
			Mix_PlayChannel(-1,cCoinCollected,0);

			m_sCoins = "";
			m_Coins += 1;
			m_bCoinsChanged = true;

			Map->SetTileAtPos( (int) (m_PosX / 32), (int) (m_PosY / 32),0,0);

		}
		else if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 6)
        {
			m_PosY = (TilePos + 1)* Tile.GetSize();
			m_VelY = 0;
			Mix_PlayChannel(-1,cBlockhit,0);
		}
		else if(Collision_Hor(m_PosX, (m_PosY - m_VelY), TilePos, Map) == 7)
        {
			m_PosY = (TilePos + 1)* Tile.GetSize();
			m_VelY = 0;
		}
		else
        {
            if (m_bLockJump == false && m_bApexReached == false)
            {
                if (m_bOffsetIsSet == false)
                {
                    m_JumpOffset = m_PosY;
                    m_JumpApex = m_JumpOffset - m_JumpingHeight;
                    m_bOffsetIsSet = true;
                }

                if (m_PosY > m_JumpApex)
                {
                    m_PosY -= m_Gravity; //Move up at same speed like we move down
                }
                else if (m_PosY <= m_JumpApex)
                {
                    m_bApexReached = true;
                    m_bLockJump = true;
                }
            }

            if (m_bApexReached == true)
            {
                m_PosY += m_Gravity;
            }
		}
	}
	else
    {
		if(Collision_Hor(m_PosX, (m_PosY + m_Gravity + m_Height), TilePos, Map) == 1)
		{
            m_PosY = (TilePos * Tile.GetSize()) - m_Height - m_Gravity;
			m_VelY = 0;

			m_bTouchesGround = true;
			m_bIsJumping = false;
			m_bLockJump = false;
			m_bApexReached = false;

		}
		else if(Collision_Hor(m_PosX, (m_PosY + m_Gravity + m_Height), TilePos, Map) == 2)
		{
			m_PosY = (TilePos * Tile.GetSize()) - m_Height - m_Gravity;
			m_VelY = 0;

			m_bTouchesGround = true;
			m_bIsJumping = false;
			m_bLockJump = false;
			m_bApexReached = false;
		}
		else if(Collision_Hor(m_PosX, (m_PosY + m_Gravity + m_Height), TilePos, Map) == 3)
		{
			m_State = "DYING";
            m_Lives -= 1;

            m_bLockJump = true;
            m_bApexReached = false;
		}
		else if(Collision_Hor(m_PosX, (m_PosY + m_Gravity + m_Height), TilePos, Map) == 5)
		{
			m_VelY = m_Gravity;
			m_Score += 100;
			m_Coins += 1;
            Mix_PlayChannel(-1,cCoinCollected,0);

			Map->SetTileAtPos( (int) (m_PosX / 32), (int) (m_PosY / 32),0,0);

			m_bLockJump = true;
		}
		else if(Collision_Hor(m_PosX, (m_PosY + m_Gravity + m_Height), TilePos, Map) == 6)
		{
			m_PosY += m_VelX;
		}
        else
        {
			m_VelY = m_Gravity;

			if(m_VelY >= Tile.GetSize())
            {
				m_VelY = Tile.GetSize();
            }
			m_bLockJump = true;
		}

		std::cout << "m_bTouchesGround: " << m_bTouchesGround << "\n";

		if (m_bTouchesGround == true)
        {
            if (m_bRight == true)
            {
                m_State = "WALKING_RIGHT";
            }
            else if (m_bLeft == true)
            {
                m_State = "WALKING_LEFT";
            }
        }
        else
        {
            m_State = "JUMPING";
        }

        m_PosY += m_VelX;
	}

	UpdateScore();
	UpdateLives();
	UpdateCoins();

    HandleStates();
}
void GameManager::UpdateGameObjects(int fElapsed)
{
    if(mGameState != GameState::GAMEPLAY)
        return;

    mCurrentTime = glutGet(GLUT_ELAPSED_TIME);

    for(unsigned int i = 0; i < GameObjects.size(); i++)
    {
        GameObject* obj = GameObjects[i];

        obj->Update(fElapsed);

        if(obj->GetType() == GameObjectType::BULLET)
        {
            if(OutofBounds(obj->GetPosition()))
                GameObjects.erase(GameObjects.begin() + i);
            else
            {
                for(GameObject* object : GameObjects)
                {
                    if(EnemyShip* enemy = dynamic_cast<EnemyShip*>(object))
                    {
                        if(Distance(enemy->GetPosition(), obj->GetPosition()) < 40)
                        {
                            GameObjects.erase(GameObjects.begin() + i);
                            enemy->SetDying(true);
                            UpdateScore();
                            break;
                        }

                    }
                }
            }
        }

        if(obj->GetType() == GameObjectType::ENEMY_SHIP)
        {
            if(dynamic_cast<EnemyShip*>(obj)->GetTimer() <= 0)
                GameObjects.erase(GameObjects.begin() + i);

            if(Distance(obj->GetPosition(), mPlayerShip->GetPosition()) < 40)
            {
                PlayerShip *playerShip = dynamic_cast<PlayerShip *>(mPlayerShip);
                if (NULL != playerShip)
                {
                    playerShip->SetDying(true);
                }
            }
        }

        if(obj->GetType() == GameObjectType::PLAYER_SHIP)
        {
            if(dynamic_cast<PlayerShip*>(obj)->GetTimer() <= 0)
                mGameState = GameState::GAMEOVER;
        }
    }

    mPreviousTime = mCurrentTime;

    //Update Game Objects as fast as the frame-rate.
    //glutTimerFunc(1000.f/60.f, UpdateGameObjects, 0);
}
Esempio n. 12
0
/******************************************************************************
*  HandleKeyPress - handle key press                                          *
******************************************************************************/
void
HandleKeyPress(char key, MyProgram *data)
{
   switch(key)
   {
      case KEY_UP:
      case KEY_DOWN:
      case KEY_LEFT:
      case KEY_RIGHT:
         HandlePlayerMove( key, data );
         break;

      case KEY_FIRE:
         HandleFire( data );
         break;

      case KEY_WARP:
         HandleWarp( data );
         break;

      case KEY_SLAMMER:
         HandleSlammer( data );
         break;

      case KEY_NEWGAME:
         UpdateStatus( "Starting new game", data );
         PopupNewGame( data );
         break;

      case KEY_OPENGAME:
         UpdateStatus( "Loading game", data );
         HandleLoadGame( data );
         break;

      case KEY_SAVEGAME:
         UpdateStatus( "Saving game", data );
         HandleSaveGame( data );
         break;

      case KEY_QUITGAME:
         UpdateStatus( "Quitting game", data );
         PopupQuit();
         break;

      case KEY_EXITGAME:
         exit(0);
         break;

      case KEY_MULTI:
         PopupMultiPlayer( data );
         break;

      case KEY_ANIM:
         ToggleAnim( data );
         break;

      case KEY_INVENTORY:
         PopupInventory( data );
         break;

      default:
         break;
   }

   UpdateScore( data );

   if (data->score.health <= 0)
   {
      PopupGameOver( data );
   }
}
Esempio n. 13
0
//Player creation method
Player::Player(SDL_Renderer *renderer, int pNum, string filePath, string audioPath, float x, float y)
{

	//activate the player
	active = true;

	//set the player number 0 or 1
	playerNum = pNum;

	//set float for player speed
	speed = 500.0f;

	laser = Mix_LoadWAV((audioPath + "bullet.wav").c_str());

	// init score and lives vars
	oldScore = 0;
	playerScore = 0;
	oldLives = 0;
	playerLives = 3;

	//init the font system
	TTF_Init();

	//load the font
	font = TTF_OpenFont((audioPath + "Amperzand.ttf").c_str(), 40);

	//see if this is player 1 or player 2, and create the correct X and Y locations
	if (playerNum == 0)
	{
		//Create the score texture X and Y position
		scorePos.x = scorePos.y = 10;
		livesPos.x = 10;
		livesPos.y = 50;
	}
	else
	{
		scorePos.x = 650;
		scorePos.y = 10;
		livesPos.x = 650;
		livesPos.y = 50;
	}

	// update score method
	UpdateScore(renderer);

	//Update lives method
	UpdateLives(renderer);

	//see if this is player 1, or player 2, and create the correct file path
	if(playerNum == 0)
	{//Create the player 1 texture
		playerPath = filePath + "player.png";
	}else
	{//Create the player 2 texture
		playerPath = filePath + "player2.png";
	}
	//load the surface
	surface = IMG_Load(playerPath.c_str());

	//load the surface into the texture
	texture = SDL_CreateTextureFromSurface(renderer, surface);

	//free the surface for later use
	SDL_FreeSurface(surface);

	//set the SDL_Rect X and Y for the player
	posRect.x = x;
	posRect.y = y;

	//Use SDL_QueryTexture to get the kW and H of the player's texture
	int w, h;

	SDL_QueryTexture(texture, NULL, NULL, &w, &h);

	posRect.w = w;

	posRect.h = h;

	//Set the movement floats to the players original X and Y
	pos_X = x;
	pos_Y = y;

	//set the xDir and yDir for the joysticks
	xDir = 0;
	yDir = 0;

	//String to create the path to the player's bullet image
	string bulletPath;

	//see if this is player 1, or player 2, and create the correct file path
	if(playerNum == 0){
		//Create the bullet 1 texture
		bulletPath = filePath + "bullet.png";
	}else{
		//Create the bullet 2 texture
		bulletPath = filePath + "bullet2.png";
	}

	//Create the player's bullet pool
	for(int i = 0; i < 10; i++)
	{
		//create the bullet and move offscreen, out of the game play area
		Bullet tmpBullet(renderer, bulletPath, -1000, -1000);

		//add to bulletlist
		bulletList.push_back(tmpBullet);

	}


}
Esempio n. 14
0
void BattleGroundIC::Update(uint32 diff)
{
    BattleGround::Update(diff);

    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    if (!doorsClosed)
    {
        if (closeFortressDoorsTimer <= diff)
        {
            // correct visual of closed gates is at "damaged" flag
            for (int i = BG_IC_GO_T_ALLIANCE_GATE_1; i <= BG_IC_GO_T_HORDE_GATE_3; ++i)
                GetBGObject(i)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);

            for (int i = BG_IC_GO_T_ALLIANCE_WEST; i <= BG_IC_GO_T_HORDE_FRONT; ++i)
                DelObject(i);

            doorsClosed = true;
        } else closeFortressDoorsTimer -= diff;
    }

    for (int node = 0; node < BG_IC_NODES_MAX; ++node)
    {
        // 3 sec delay to spawn new banner instead previous despawned one
        if (m_BannerTimers[node].timer)
        {
            if (m_BannerTimers[node].timer > diff)
                m_BannerTimers[node].timer -= diff;
            else
            {
                m_BannerTimers[node].timer = 0;
                _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false);
            }
        }

        // 1-minute to occupy a node from contested state
        if (m_NodeTimers[node])
        {
            if (m_NodeTimers[node] > diff)
                m_NodeTimers[node] -= diff;
            else
            {
                m_NodeTimers[node] = 0;
                // Change from contested to occupied !
                uint8 teamIndex = m_Nodes[node]-1;
                m_prevNodes[node] = m_Nodes[node];
                m_Nodes[node] += 2;
                // create new occupied banner
                _CreateBanner(node, BG_IC_NODE_TYPE_OCCUPIED, teamIndex, true);
                _SendNodeUpdate(node);
                // Message to chatlog
                if (teamIndex == TEAM_INDEX_ALLIANCE)
                {
                    SendMessage2ToAll(LANG_BG_IC_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_ALLIANCE,NULL,LANG_BG_ALLY,_GetNodeNameId(node));
                    PlaySoundToAll(BG_IC_SOUND_NODE_CAPTURED_ALLIANCE);
                }
                else
                {
                    SendMessage2ToAll(LANG_BG_IC_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_HORDE,_GetNodeNameId(node));
                    PlaySoundToAll(BG_IC_SOUND_NODE_CAPTURED_HORDE);
                }

                // gunship starting
                if (node == BG_IC_NODE_HANGAR)
                    (teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap());
            }
        }
    }

    // add a point every 45 secs to quarry/refinery owner
    for (uint8 node = BG_IC_NODE_QUARRY; node <= BG_IC_NODE_REFINERY; node++)
    {
        if (m_Nodes[node] >= BG_IC_NODE_TYPE_OCCUPIED)
        {
            if (m_resource_Timer[node] <= diff)
            {
                UpdateScore(TeamIndex(m_Nodes[node] - BG_IC_NODE_TYPE_OCCUPIED) , 1);
                RewardHonorToTeam(GetBonusHonorFromKill(1), (m_Nodes[node] - BG_IC_NODE_TYPE_OCCUPIED == 0 ? ALLIANCE : HORDE));
                m_resource_Timer[node] = BG_IC_RESOURCE_TICK_TIMER;
            }
            else
                m_resource_Timer[node] -= diff;
        }
    }
    HandleBuffs();
}
Esempio n. 15
0
void MovePac(struct Player *P)
{
  int nx,ny,goo=0,dx=0,dy=0,part;
  bool Check=false;
  P->mc++;
  if(WakaFlag) { WakaFlag=0; P->cur=P->old; }
  else {
    WakaFlag=1;  P->old=P->cur;  P->cur=SPR_PACNONE;
    //destw->draw(picts[SPR_PACNONE],P->zx,P->zy);
    destw->copyBlock(srcs,picts[SPR_PACNONE]->x,picts[SPR_PACNONE]->y,P->zx,P->zy,BITMAP_X,BITMAP_Y);
  }
  if(P->mc==P->speed) {
    if((P->bx==0)&&(P->by==5)) { DoTunnel(P,LEFT_TUNNEL); } else
    if((P->bx==18)&&(P->by==5)) { DoTunnel(P,RIGHT_TUNNEL); }
    P->mc=0;
    nx=P->zx;  ny=P->zy;
    if(P->mcnt==CountMax) Check=true;
    if(P->mcnt<0) Check=true;
    if(Check) {
      P->mcnt=0;  P->dir=P->nextdir;
    }
    switch(P->dir) {
      case DIR_UP:    dy= -1; P->cur=SPR_PACUP; break;
      case DIR_DOWN:  dy=1;  P->cur=SPR_PACDOWN; break;
      case DIR_LEFT:  dx= -1; P->cur=SPR_PACLEFT; break;
      case DIR_RIGHT: dx=1;  P->cur=SPR_PACRIGHT; break;
      default: break;
    }
    dx=dx*AspectX;  dy=dy*AspectY;
    //dy=DirY[P->dir];  dx=DirX[P->dir];
    //P->cur=(*shapes)[P->dir];
    if(Check) {
      P->lx=(nx+BITMAP_X/2)/BITMAP_X;  P->ly=(ny+BITMAP_Y/2)/BITMAP_Y;
      part=ReadBoard(P->bx,P->by);
      if((part)==(int)'.') {
        WriteBoard(P->bx,P->by,(int)',');  NumDots--;  NumPoints+=1;
        UpdateScore();
      } else
      if((part)==(int)'*') {
        WriteBoard(P->bx,P->by,(int)',');  NumDots--;  NumPoints+=10;
        UpdateScore();  DoMyBlue();
      }
      /*P->lx=(nx+BITMAP_X/2)/BITMAP_X;  P->ly=(ny+BITMAP_Y/2)/BITMAP_Y;*/
      goo=CheckSpace(nx,ny,&dx,&dy);
      if(goo) {
        P->dir=DIR_STOP;  P->nextdir=DIR_STOP;
      }
    }
    if(!goo) {
      if(FOOBAR_PACMOVE)
        DrawBoardPart(P->lx,P->ly,ReadBoard(P->lx,P->ly));
      nx+=dx;  ny+=dy;
      P->mcnt++;
#ifdef CATCH_OUT
      if(ny<0) { ny=1; P->dir=DIR_DOWN; }
      if(ny>SCREEN_Y+BITMAP_X) { ny=SCREEN_Y-2; P->dir=DIR_UP; }
      if(nx<0) { nx=1; P->dir=DIR_RIGHT; }
      if(nx>SCREEN_X) { nx=SCREEN_X-2; P->dir=DIR_LEFT; }
#endif
      if(WakaFlag) {
        //destw->draw(picts[P->cur],nx,ny);
        destw->copyBlock(srcs,picts[P->cur]->x,picts[P->cur]->y,nx,ny,BITMAP_X,BITMAP_Y);
      }
      else {
        //destw->draw(picts[SPR_PACNONE],nx,ny);
        destw->copyBlock(srcs,picts[SPR_PACNONE]->x,picts[SPR_PACNONE]->y,nx,ny,BITMAP_X,BITMAP_Y);
      }
      P->zx=nx;  P->zy=ny;
      P->bx=(nx+BITMAP_X/2)/BITMAP_X;  P->by=(ny+BITMAP_Y/2)/BITMAP_Y;
    }
  }
}
Esempio n. 16
0
Player::Player(SDL_Renderer *renderer,int pNum,string filePath,string audioPath,float x,float y)
{
	active = true;

	playerNum = pNum;

	speed=500.0f;

	laser = Mix_LoadWAV((audioPath + "/lazer.wav").c_str());

	//init for score and lives var
	oldScore=0;
	playerScore=0;
	oldLives=0;
	playerLives=3;

	TTF_Init();

	font = TTF_OpenFont((audioPath + "/Comic.ttf").c_str(), 40);

	if(playerNum==0){
		scorePos.x=scorePos.y=10;
		livesPos.x=10;
		livesPos.y=40;
	}else{
		scorePos.x=650;
		scorePos.y=10;
		livesPos.x=650;
		livesPos.y=40;
	}

	//update score method
	UpdateScore(renderer);

	UpdateLives(renderer);

	if(playerNum==0){
		playerpath = filePath + "/Player1.png";
	}else{
		playerpath = filePath + "/Player2.png";
	}
	surface = IMG_Load(playerpath.c_str());

	texture = SDL_CreateTextureFromSurface(renderer,surface);

	SDL_FreeSurface(surface);

	posRect.x=x;

	posRect.y=y;

	int w,h;

	SDL_QueryTexture(texture,NULL,NULL,&w,&h);

	posRect.w=w;

	posRect.h=h;

	pos_X=x;
	pos_Y=y;

	xDir=0;
	yDir=0;

	string bulletPath;

	if (playerNum == 0) {

		bulletPath = filePath + "/bullet.png";
	}
	else {
		bulletPath = filePath + "/bullet2.png";
	}

	for (int i = 0; i < 10; i++)
	{
		Bullet tmpBullet(renderer, bulletPath, -1000, -1000);

		bulletList.push_back(tmpBullet);
	}

}
Esempio n. 17
0
int main(int argc, char **argv)
{
  aThisApp.start(argc,argv);
  char *fname=(char *)NULL;
  if(aThisApp.argc>1) fname=aThisApp.argv[1];
  if(aThisApp.argc<2) {
    ARequesterFile *ww=new ARequesterFile();
    if(ww) fname=ww->show((char *)"Open file");
    else std::cerr<<"(Didn't get a request window)\n";
    if(ww) delete ww;
    ww=NULL;
  }
  if(!fname) {
    char msg[256];
    sprintf(msg,(char *)"usage: nupac {board filename}",aThisApp.argv[0]);
    ADialogMsg mw((char *)"Error!",msg);
    //return 5;
    return 0;
  }
  char *bname=fname;
  unsigned int t;
  char *temp;
  InitGame();
  for(t=1;t<aThisApp.argc;t++) {
    temp=aThisApp.argv[t];
    if(temp[0]=='-') {
      if(temp[1]=='d') {
        DisplayName=aThisApp.argv[t+1]; t++;  std::cerr<<"Display name is ";
        std::cerr<<DisplayName<<"\n";
      } else
      if(temp[1]=='p') { FOOBAR_PACMOVE=false; } else
      if(temp[1]=='m') { FOOBAR_MONO=1; } else
      if(temp[1]=='s') {
        sscanf(aThisApp.argv[t+1],(char *)"%d",(unsigned int *)&SPEED);
        t++;
        std::cerr<<"New speed is";
        std::cerr<<SPEED<<"\n";
      } else
      std::cerr<<aThisApp.argv[0]<<": bad command option\n";
    }
    else {
      bname=temp;
    }
  }
  std::cerr<<"Initial board is "<<bname<<"\n";
  DoTitle();
  QUITING=false;
  while(!QUITING) {
    std::cerr<<"Looping in main while !QUITING...\n";
    //StartLoading();
    CleanupBitmaps();
    if(bname) ReadBoardFromDisk(bname);
    else boardError=true;
    if(boardError) {
      QUITING=true;
    }
    else {
      ExploreBoard();
      SetupBitmaps();
      if(!QUITING) {
        SetSpriteShapes();
        DrawScreen();
        UpdateScore();  InitRound();
        DIED=true;
        while(DIED) {
          mainloop();
          UpdateScore();  InitRound();
          if(QUITING) DoQuit();
        }
      }
      bname=NextBoard;  boardError=false;
    }
  }
  std::cerr<<"Normal exit\n";
  return 0;
}
Esempio n. 18
0
void ScoreboardSurface::Start()
{
	m_score = 0;
	UpdateScore();
	AbstractTimerSurface::Start();
}
Esempio n. 19
0
void CGuildManager::Update()
{
	ProcessReserveWar(); // 예약 전쟁 처리

	time_t now = CClientManager::instance().GetCurrentTime();

	if (!m_pqOnWar.empty())
	{
		// UNKNOWN_GUILD_MANAGE_UPDATE_LOG
		/*
		   sys_log(0, "GuildManager::Update size %d now %d top %d, %s(%u) vs %s(%u)", 
		   m_WarMap.size(),
		   now,
		   m_pqOnWar.top().first,
		   m_map_kGuild[m_pqOnWar.top().second->GID[0]].szName,
		   m_pqOnWar.top().second->GID[0],
		   m_map_kGuild[m_pqOnWar.top().second->GID[1]].szName,
		   m_pqOnWar.top().second->GID[1]);
		   */
		// END_OF_UNKNOWN_GUILD_MANAGE_UPDATE_LOG

		while (!m_pqOnWar.empty() && (m_pqOnWar.top().first <= now || (m_pqOnWar.top().second && m_pqOnWar.top().second->bEnd)))
		{
			TGuildWarPQElement * e = m_pqOnWar.top().second;

			m_pqOnWar.pop();

			if (e)
			{
				if (!e->bEnd)
					WarEnd(e->GID[0], e->GID[1], false); 

				delete e;
			}
		}
	}

	// GUILD_SKILL_COOLTIME_BUG_FIX
	while (!m_pqSkill.empty() && m_pqSkill.top().first <= now)
	{
		const TGuildSkillUsed& s = m_pqSkill.top().second;
		CClientManager::instance().SendGuildSkillUsable(s.GID, s.dwSkillVnum, true);
		m_pqSkill.pop();
	}
	// END_OF_GUILD_SKILL_COOLTIME_BUG_FIX

	while (!m_pqWaitStart.empty() && m_pqWaitStart.top().first <= now)
	{
		const TGuildWaitStartInfo & ws = m_pqWaitStart.top().second;
		m_pqWaitStart.pop();

		StartWar(ws.bType, ws.GID[0], ws.GID[1], ws.pkReserve); // insert new element to m_WarMap and m_pqOnWar

		if (ws.lInitialScore)
		{
			UpdateScore(ws.GID[0], ws.GID[1], ws.lInitialScore, 0);
			UpdateScore(ws.GID[1], ws.GID[0], ws.lInitialScore, 0);
		}

		TPacketGuildWar p;

		p.bType		= ws.bType;
		p.bWar		= GUILD_WAR_ON_WAR;
		p.dwGuildFrom	= ws.GID[0];
		p.dwGuildTo	= ws.GID[1];

		CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR, &p, sizeof(p));
		sys_log(0, "GuildWar: GUILD sending start of wait start war %d %d", ws.GID[0], ws.GID[1]);
	}
}