Ejemplo n.º 1
0
void PlayState::update(const double dt) {

	for (LevelItem::ObjListConstIter obj = objectList.begin(); obj < objectList.end(); obj++)
		(*obj)->update(dt);

	player->collectActions(playerActions);
	player->update(dt);
	playerActions.clear();

	//iterating through objectList, removing items maraked for removal, whilst not invalidating iterator
	for (LevelItem::ObjListConstIter obj = objectList.begin(); obj != objectList.end(); /*empty*/) {
		if ((*obj)->markedForRemoval)
			obj = objectList.erase(obj);
		else 
			++obj;
	}

	if (player->markedForRemoval)
		endGame(PLAYER_DIED);

	for (LevelItem::ObjListConstIter obj = objectList.begin(); obj < objectList.end(); obj++) {
		Checkpoint* cp = dynamic_cast<Checkpoint*>(*obj);
		if (cp && cp->cptype == Checkpoint::LEVEL_END && cp->activated)
			endGame(END_REACHED);
	}
}
Ejemplo n.º 2
0
void GameSession::black_offersDraw()
{
   if(whiteDrawOfferActive_)
   {
      whiteDrawOfferActive_ = false;
      whitePlayer_->opponentAcceptsDraw();
      //
      g_localChessGui.showSessionMessage(
            g_msg("PlayerAcceptsDraw").arg(blackPlayer_->name()));
      //
      endGame(reasonGameFinished, resultDrawnByAgreement);
   }
   else if(canDrawByRepetition_)
   {
      endGame(reasonGameFinished, resultDrawnByRepetition);
   }
   else
   {
      blackDrawOfferActive_ = true;
      whitePlayer_->opponentOffersDraw();
      //
      g_localChessGui.showSessionMessage(
            g_msg("PlayerOffersDraw").arg(blackPlayer_->name()));
   }
}
Ejemplo n.º 3
0
int			main(int UNUSED(argc), char ** argv, char **envp)
{
	Game *			game = init_game();
	int				i = -1;
	std::string		visual[] = {
		" ",
		"*",
		" ",
		"~"
	};

	while (++i < WIN_WIDTH )
	{
		game->getBg()[i].setY(0);
		game->getBg()[i].setPatern(Patern(visual[rand() % 4]));
		game->getBg2()[i].setY(WIN_HEIGHT - 1);
	}
	while ( 42 )
	{
		usleep( 1000000 / NB_FRAME );
		if ( doKeyAction(game->getPlayer()) )
			break ;
		game->popRandomEnemy();
		game->move_all();
		if (checkCollisions(game, game->getEnemies(), game->getPlayer()->getBullets()))
			endGame(game->getPlayer()->getScore(), argv[0], envp, "You Win !");
		if (game->getPlayer()->getHp() <= 0)
			break ;
		clear();
		game->display_all();
	}
	endGame(game->getPlayer()->getScore(), argv[0], envp, "You loose !");

	COUT << ENDL;
}
Ejemplo n.º 4
0
void nextTurn(int field[n][n],int crossFlag)
{
    if (crossFlag%2==0)
        printf("\nX turn\nEnter X Y (sample '1 2' or '3 1'):\n");
    else
        printf("\nO turn\nEnter X Y (sample '1 2' or '3 1'):\n");
    int x,y;
    do
    {
        scanf("%d%d",&x,&y);
        if (field[x-1][y-1]!=0)
            printf("\nIncorrect move. Please repeat again.\nEnter X Y (sample '1 2' or '3 1'):\n");
    }
    while (field[x-1][y-1]!=0);
    system("cls");
    if (crossFlag%2==0)
        field[x-1][y-1]=1;
    else
        field[x-1][y-1]=2;
    drawField(field);
    if (endGame(field)==1 && crossFlag%2==0)
        printf("\nX Win!\n");
    if (endGame(field)==1 && crossFlag%2!=0)
        printf("\nO Win!\n");
    if (endGame(field)==2)
        printf("\nDraw!\n");
}
Ejemplo n.º 5
0
UserControlsEngine::UserControlsEngine(GameEngine *ge): gameEngine(ge), hasEnd(false), hasBegin(true),pauseTime(NOVATIMER)
{
    myKey = Settings::getGlobalSettings().playersControls();

    display = gameEngine->displayEngine();

    actions.insert(myKey[aTop1],aTop1);
    actions.insert(myKey[aBottom1],aBottom1);
    actions.insert(myKey[aShoot1],aShoot1);

    actions.insert(myKey[aTop2],aTop2);
    actions.insert(myKey[aBottom2],aBottom2);
    actions.insert(myKey[aShoot2],aShoot2);

    novaeCall = new QTimer(this);
    novaeCall->setSingleShot(true);
    novaeCall->start(NOVATIMER);
    countTimer.start();
    idTimer = startTimer(REFRESH);

    connect(novaeCall,SIGNAL(timeout()),this,SLOT(callSupernovae()));
    connect(gameEngine,SIGNAL(signalPause(bool)),this,SLOT(pauseGame(bool)));
    connect(gameEngine,SIGNAL(endGame()),this,SLOT(endGame()));

}
Ejemplo n.º 6
0
void Game::changeTurn() {
    /* Change le joueur en cours */
    turn = (turn == 1)?2:1;
    
    //player1.computeAvailableMovements(player1.getPieces(), player2.getPieces());
    //player2.computeAvailableMovements(player2.getPieces(), player1.getPieces());

    computeAvailableMovements();

    scene->unselect();


    if(turn == 1){

        std::vector<Piece *> checkState = check(player1, player2, player1.getKing()->getPosition());
        if (checkState.size()>0){
            std::cout << "\nJoueur 1, vous êtes en échec !" << std::endl;
            scene->setSelectTex(1);
            if(checkMate(player1, player2,checkState)) endGame(2);
        } else {
            scene->setSelectTex(0);
        }
    } else if (turn == 2){
        std::vector<Piece *> checkState = check(player2, player1, player2.getKing()->getPosition());
        if (checkState.size()){
            std::cout << "\nJoueur 2, vous êtes en échec !" << std::endl;
            scene->setSelectTex(1);
            if(checkMate(player2, player1, checkState)) endGame(1);
        } else {
            scene->setSelectTex(0);
        }
    }
}
Ejemplo n.º 7
0
void GameManager::initCards()
{
	QStringList cardsNames, c1, c2;
	int i = 0, j = 0, k = 0;
	
	c1 << "king" << "queen" << "jack";
	c2 << "club" << "diamond" << "heart" << "spade"; 
	
	for(i = 0; i < c2.count(); i++)
	{
		for(j = 0; j < c1.count(); j++)
			cardsNames << c1.at(j) + "_" + c2.at(i);
		for(k = 1; k <= 10; k++)
			cardsNames << QString().setNum(k) + "_" + c2.at(i);
	}
	cardsNames += cardsNames;
	
	shuflleCards(cardsNames);
	setCards(cardsNames);
	
	connect(&(basePiles.at(0)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(1)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(2)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(3)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(4)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(5)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(6)) , SIGNAL(fullPileBase()), SLOT(endGame()));
	connect(&(basePiles.at(7)) , SIGNAL(fullPileBase()), SLOT(endGame()));
}
Ejemplo n.º 8
0
void MainWindow::onTimerTick()
{
    Figure newFig = *cur_figure;
    newFig.setPosition(newFig.getPosition().x(), cur_figure->getPosition().y() + 1);
    if (m_cup.hasPlace(newFig)) {
        delete cur_figure;
        cur_figure = new Figure(newFig);
    } else {
        m_cup.putFigure(*cur_figure);
        m_score += m_cup.clearedLines() * 100 + (m_cup.clearedLines() > 0 ? 100 : 0);
        if (m_score >= NEXTLEVELSCORE) {
            m_score = 0;
            if (m_level < MAX_LEVEL)
                m_level++;
            else
                endGame();
            init();
        }
        delete cur_figure;
        cur_figure = new Figure(m_cup);
        if (m_cup.filled())
            gameOver();
    }
    draw();
}
Ejemplo n.º 9
0
void ACSUEGameMode::endRound(FString winningTeam){
    if(winningTeam == FString(TEXT("t")))
        tWins+=1;
    else
        ctWins+=1;
	//reset round time
	GetWorldTimerManager().ClearTimer(roundTimer);
	time = 180;
	//start new round if game is not over
	if (tWins == 5 || ctWins == 5)
		endGame(winningTeam);
	else {

		startRound();
		auto myChar = (ACSUECharacter*)UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
		if (myChar->myTeam == FString(TEXT("CT"))) {
			FVector spawn = FVector(-3163.f, 1183.f, -227.f);
			myChar->SetActorRotation(FRotator::ZeroRotator);
			myChar->SetActorLocation(spawn, false);

		}
		else {
			FVector spawn = FVector(-6305.f, 9740.f, 584.f);
			myChar->SetActorRotation(FRotator::ZeroRotator);
			myChar->SetActorLocation(spawn, false);
		}
	}

}
Ejemplo n.º 10
0
void MainMenu::touchEvent(Ref *pSender, TouchEventType type)
{
    switch (type)
    {
        case TOUCH_EVENT_ENDED:

			if (pSender)
			{
				Node *node = static_cast<Node*>(pSender);
				if (node)
				{
					switch (node->getTag())
					{
					case 1:
						gotoBattleScene();
						break;
					case 2:
						endGame();
						break;
					default:
						break;
					}
				}
			}

            break;
            
        default:
            break;
    }
}
Ejemplo n.º 11
0
  void MainWindow::initMenu()
  {
    KStandardAction::preferences(this, SLOT(onPreferences()), actionCollection());
    
    m_menu.m_newAction = new QAction(QIcon::fromTheme("file_new"), i18n("&New game"), this);
    actionCollection()->setDefaultShortcut(m_menu.m_newAction, Qt::CTRL + Qt::Key_N);
    
    connect(m_menu.m_newAction, SIGNAL(triggered(bool)), this, SLOT(onNewGame())); 

    actionCollection()->addAction("NewGame", m_menu.m_newAction);
    
    m_menu.m_endAction = actionCollection()->addAction("EndGame", this, SLOT(endGame()));
    m_menu.m_endAction->setIcon(QIcon::fromTheme("window-close"));
    m_menu.m_endAction->setText(i18n("&End game"));
    actionCollection()->setDefaultShortcut(m_menu.m_endAction, Qt::CTRL + Qt::Key_E);
    m_menu.m_endAction->setEnabled(false);
    
    m_menu.m_quitAction = actionCollection()->addAction("Quit", this, SLOT(close()));
    m_menu.m_quitAction->setIcon(QIcon::fromTheme("exit"));
    m_menu.m_quitAction->setText(i18n("&Quit"));
    actionCollection()->setDefaultShortcut(m_menu.m_quitAction, Qt::CTRL + Qt::Key_Q);
    
    m_menu.m_undoAction = actionCollection()->addAction("UndoGame", this);
    m_menu.m_undoAction->setIcon(QIcon::fromTheme("undo"));
    m_menu.m_undoAction->setText(i18n("&Undo"));
    m_menu.m_undoAction->setEnabled(false);
    actionCollection()->setDefaultShortcut(m_menu.m_undoAction, Qt::CTRL + Qt::Key_Z);
  }
Ejemplo n.º 12
0
void deleteGame::delPts()
{
    if( pts!= 0)
        pts--;
    else
        emit endGame(0);
}
Ejemplo n.º 13
0
void GameMenuUserInterface::processSelection(U32 index)
{
   switch(index)
   {
      case 1:
         gOptionsMenuUserInterface.activate();
         break;
      case 2:
         gInstructionsUserInterface.activate();
         break;
      case 3:
         endGame();
         if(EditorUserInterface::editorEnabled)
            gEditorUserInterface.activate();
         else
            gMainMenuUserInterface.activate();
         break;
      case 4:
         gAdminMenuUserInterface.activate();
         break;
      case 5:
         gAdminPasswordEntryUserInterface.activate();
         break;
      default:
         gGameUserInterface.activate();
         if(mGameType.isValid())
            mGameType->processClientGameMenuOption(index);
         break;
   }
}
Ejemplo n.º 14
0
void handle(uint8_t t) {
	if(t < 11 && t > 0) { //wcisniety ktorys z pierwszych dziesieciu klawiszy
		if(position < 4){ //jezeli jest miejsce
			sendData(t+47); //wypisujemy cyfre
			result[position] = t+47; //ustawiamy cyfre na danej pozycji
			position++; //zwiekszamy pozycje na ktorej wpisujemy nastepna cyfre
			LCDposition++;
		}
	} else if(t == 11) { //klawisz cofania
		if(position > 0) { //jezeli juz cos wpisalismy
			clearOneCharacter(); //usuwamy z wyswietlacza ostatni znak
			position--; //zmniejszamy pozycje do wpisywania
			LCDposition--;
			result[position] = 0; //ucinamy stringa na ostatnim miejscu
		}
	} else if(t == 12) { //klawisz zatwierdzania
		checkResult(); //sprawdz czy wynik jest ok
		if(tries < TRIES_COUNT) { //jezeli nie odpowiedzielismy na zadana liczbe pytan dobrze
			playOneTry(); //gramy nastepna runde
		} else {
			if(player == 1) { //jezeli gracz pierwszy skonczyl
				playerOneTime = time; //zapisujemy jego czas
				player = 2; //zmieniamy gracza
				isStarted = 0; //stopujemy gre
				initGame(); //inicjalizujemy gre
                
			} else {
				playerTwoTime = time; //zapisujemy czas drugiego gracz
				endGame(); //konczymy gre
			}
		}
	}
}
Ejemplo n.º 15
0
  void GameState::handleTick() {
    if (SDL_GetTicks() > nextRound_) {
      roundNumber_++;
      nextRound_ += constants::ROUND_LENGTH;
      lives_ = 4;
    }
    if (SDL_GetTicks() > nextCircle_) {
      addScoreArea();
      calcNextCircle();
    }
    if (SDL_GetTicks() > nextCircleDeath_) {
      size_t pos = -1;
      for (size_t i = 0; i < scoreAreas_.size(); i++) {
        ScoreArea* sa = scoreAreas_.at(i);
        Uint32 age = SDL_GetTicks() - sa->getCreationTime();
        if (age < constants::SCOREAREA_MAX_AGE) {
          pos = i;
          break;
        }
      }
      if (pos != -1) {
	      for (size_t i = 0; i < pos; i++) {
          ScoreArea* sa = scoreAreas_.at(0);
		      scoreAreas_.erase(scoreAreas_.begin());
          lives_--;
          delete sa;
        } 
      }
    }
    if (lives_ == 0) {
      endGame();
    }
  }
Ejemplo n.º 16
0
void update(int *bx, int *by, bool *running)
{
	int keyIn = getKeyboardInput();
	if(keyIn != 0)
	{
		switch(keyIn)
		{
		case 27: // [ESC]
			endGame(running);
			break;
		case 224: // Special key
			int keyIn2= getKeyboardInput();
			switch(keyIn2)
			{
			case 75: // [<-]
				*bx = *bx-1;
				break;
			case 77: // [->]
				*bx = *bx+1;
				break;
			case 80: // [ v ]
				*by = *by+1;
				break;
			}
			break;
		}
	}
	else
		*by = *by+1;
}
Ejemplo n.º 17
0
char* action(player* pl, player* w, int in){
    char* msg = "";
    switch(in){
        case KEY_UP:
            msg = playerMove(pl, UP, w);
            break;
        case KEY_DOWN:
            msg = playerMove(pl, DOWN, w);
            break;
        case KEY_LEFT:
            msg = playerMove(pl, LEFT, w);
            break;
        case KEY_RIGHT:
            msg = playerMove(pl, RIGHT, w);
            break;
        case KEY_SHOOT:
            switch(in = input()){
                case KEY_DOWN: msg = playerShoot(pl, DOWN, w); break;
                case KEY_LEFT: msg = playerShoot(pl, LEFT, w); break;
                case KEY_RIGHT: msg = playerShoot(pl, RIGHT, w); break;
                case KEY_UP: msg = playerShoot(pl, UP, w); break;
                default: break;
            }
            break;
        case KEY_QUIT:
            endGame(pl, w);
            break;
        default: break;
    }
    return msg;
}
Ejemplo n.º 18
0
void OgreApp::setPause(bool value)
{
    if (value)
    {
        pause = value;
        player->pause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->pauseAllSounds();
        if (predictSessionOver())
        {
            if (player->getName() == "subject999")
                globals.setMessage("Training is complete!\nPlease check in.\n\nDouble tap to exit.", MESSAGE_FINAL);
            else
                globals.setMessage("That's it for Today!\nPlease check in before you leave.\n\nYou completed: " + Util::toStringInt(player->getNumStagesWon()) + " stages!\n\nDouble tap to exit.", MESSAGE_FINAL);
            endGame();
        }
        else
        {
            globals.appendMessage("\n\nSwipe to Continue", MESSAGE_NORMAL);
#ifdef DEBUG_MODE
            globals.appendMessage("\n\n" + player->getSkillLevel().getCurrentStats(), MESSAGE_NORMAL);
            globals.appendMessage("\n\n" + Util::toStringInt(globals.sessionTime - getTotalElapsed()), MESSAGE_NORMAL);
#endif
        }
        Ogre::ControllerManager::getSingleton().setTimeFactor(0);
    }
    else if (!sessionOver)
    {
        pause = value;
        player->unpause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->resumeAllPausedSounds();
        
        globals.clearMessage();
        Ogre::ControllerManager::getSingleton().setTimeFactor(1);
    }
}
Ejemplo n.º 19
0
//侦听子元素链接开始
void HelloWorld::BeginContact(b2Contact* contact) {
	if(contact->GetFixtureA()->GetBody()->GetUserData()==bird||
	   contact->GetFixtureB()->GetBody()->GetUserData()==bird){
			  CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("mp3/dead.wav");
			  endGame();
		  // CCMessageBox("游戏失败","游戏失败");
	}
}
Ejemplo n.º 20
0
void Window::newGame() {
	if (endGame()) {
		NewGameDialog dialog(this);
		if (dialog.exec() == QDialog::Accepted) {
			startGame();
		}
	}
}
Ejemplo n.º 21
0
void GameController::restartGame()
{
	if (isGameStarted_)
	{
		endGame();
		startGame();
	}
}
Ejemplo n.º 22
0
bool playGame(Affichage A, Damier *map, Snake *snake, Sound sound)
{
	int end = 0;
	bool win = FALSE;
	Position newPos = initPosition();
	Input input = initInput();
	Chrono chrono = initChrono();
	Timer timer = initTimer();
	
	
	setProiesToMap(map);
	
	drawTile(A, TILE_TITLE);
	drawTextChrono(chrono, A);
	drawMap(A, *map, newPosition(MAXCASES/2 + 3,MAXCASES/2), *snake);

	startChrono(&chrono);
	while (1)
	{
		
		setTimer(&timer);
		newPos = updatePositions(map, snake, &input);
		
		if (input.end)
			break;

		if (testPosMap(newPos))
		{
			end = addPositionSnake(map, snake, newPos, sound);
			if (end)
			{
				win = FALSE;
				break;
			}
		}
		
		setPositionsToMap(map, snake);
		drawChrono(chrono, A);
		drawMap(A, *map, newPos, *snake);
		
		if(endChrono(chrono))
		{
			win = FALSE;
			break;
		}
		
		if (endGame(map))
		{
			win = TRUE;
			break;
		}
		
		reguleFPS(&timer);
	}
	
	deleteChrono(&chrono);
	return win;
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
void testApp::draw(){
	bgImg.draw(0, 0);
	for(Circles::iterator i = circles.begin(); i != circles.end(); i++){
		(*i)->draw();
	}

	// draw HUD
	{
		ofPushStyle();
		ofSetColor(0, 0, 0, 125);
		ofRect(0, 0, ofGetWidth(), 30);
		ofPopStyle();
	}

	// Draw cooldown
	{

		float width = 100;
		ofPushStyle();
		ofSetColor(0, 255, 255);
		int CDWait = ofGetElapsedTimeMillis() - lastTimeUsed;
		if(CDWait < cooldown){
			width = 100 * CDWait/cooldown;

		}
		ofRect(5, 5, width, 20);
		ofPopStyle();

		ofPushStyle();
		ofNoFill();
		ofSetColor(0);
		ofRect(5, 5, 100, 20);
		ofPopStyle();
	}
	// Draw points
	{
		ofPushStyle();
		ofSetColor(255);
		stringstream ss;
		ss << "Points: " << points;

		ofDrawBitmapString(ss.str(), ofGetWidth() - 100, 20);

		ofPopStyle();
	}

	// Draw time
	{
		stringstream ss;
		ss << "Time remaining: " << tRemaining / 1000;

		ofDrawBitmapString(ss.str(), ofGetWidth() / 2, 20);
	}

	// end game
	if(gameOver) endGame();

}
Ejemplo n.º 24
0
int main(int argc, const char * argv[]) {
    // ask for player 1's name and player 2's name
    
    printf("Player 1's name? ");
    fgets(player1.name, 255, stdin);
    
    printf("Player 2's name? ");
    fgets(player2.name, 255, stdin);
    
    // initialize player 1 and player 2's lives (use function "setupNewGame")
    setupNewGame();
    
    
    
    // start game loop
    
    while (playingGame == true) {
        
        //askQuestion(playersTurn);
        
        if(askQuestion(playersTurn)) {
            // Question was answered correctly
            if (playersTurn == 1) {
                player1.score++;
            } else if (playersTurn == 2) {
                player2.score++;
            }
            printf("Right! \n");
        } else {
            // Question was answered incorrectly
            printf("Nope! \n");
            
            // Remove a life
            if (playersTurn == 1) {
                player1.lives--;
                printf("Player 1 Lives = %d \n", player1.lives);
            } else if (playersTurn == 2) {
                player2.lives--;
                printf("Player 2 Lives = %d \n", player2.lives);
            }
            
            printf("Player 1 Score = %d \nPlayer 2 Score = %d \n", player1.score, player2.score);
        }
        
        if (playersTurn == 1) {
            playersTurn++;
        } else {
            playersTurn = 1;
        }
        
        if (player1.lives == 0 || player2.lives == 0) {
            endGame();
        }
        
    }
    
    return 0;
}
Ejemplo n.º 25
0
void EndGameSlot::onCall(bool isOnTimeout, Packet *packet, Protocol::Protocol *proto, void *data)
{
    if (isOnTimeout || !packet || !proto || !data)
        return ;

    std::cout << "END GAME SLOT" << std::endl;

    emit endGame();
}
Ejemplo n.º 26
0
//updates gary the ghost to move about
void updateGary() {

	speed += acceleration;
	gary.xPos += speed;
	
	if(isHit())
		endGame();
	
}
Ejemplo n.º 27
0
void GameScene::update(float dt)
{
    _skyPos = _backgroundNode->getPosition();
    CCPoint backgroundScrollVert = ccp(_backgroundPointsPerSecX,0);
    if(_skyPos.x >= -11900.0 && _skyPos.x < 1)
    {
    //    backgroundScrollVert = ccp(-1000, 0);
        _backgroundNode->setPosition(ccpAdd(_backgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));
    }else
    {
        if(_skyPos.x <= -11900)
        {
            if (_backgroundPointsPerSecX > 0.0f) {
                _backgroundNode->setPosition(ccpAdd(_backgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));
            }
        }
        if (_skyPos.x >=1) {
            if (_backgroundPointsPerSecX < 0.0f) {
                _backgroundNode->setPosition(ccpAdd(_backgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));
            }
        }
    }
    
    for(int i=0;i<4;i++)
    {
        RotatingShell *s =  (RotatingShell *)_rotatingShells->objectAtIndex(i);
        
        if (s->isVisible) {
            if(s->_shell->getPositionY()<0)
                s->isVisible = false;
            s->update(dt);
        }
        
    }
    
    _gameLogic->update(dt);
    
    if (_spawnTime >=2.0f) {
        this->spawnChicken();
        _spawnTime = 0.0f;
    }else
    {
        _spawnTime += dt;
    }
    
    for (int i=0; i<_flyingChickens->count(); i++) {
        FlyingChicken * fc = (FlyingChicken *)_flyingChickens->objectAtIndex(i);
        if (!fc->isVisible()) {
            _flyingChickens->removeObjectAtIndex(i);
            
        }
        
    }
    if (_gameLogic->getTime() <= 0) {
        endGame();
    }
}
Ejemplo n.º 28
0
   void PlayScene::update(Engine& ctx)
   {
      if(m_status == Playing)
      {
         if(m_player -> reachedExit())
         {
            endGame(ctx);
            m_status = Playing;
            ctx.setScene("end");
            return;
         }

         m_player -> update(ctx);

         if(m_player -> x() - m_threat -> x() > 512)
         {
            m_threat -> setX(m_player -> x() - 512);
         }
         m_threat -> update(ctx);
         m_threat->setY(m_player->y()); // Just to make sure it can always hit the player
         
         updateCamera(ctx);   
         m_player->setMinX(m_cam -> x()); // Player can't walk past the left edge of the screen

         // The youngling eater follows the camera. If any younglings go off-screen, they'll get omnomnommed.
         m_eater->setX(m_cam -> x());
         m_eater->setY(m_cam -> y());

         // Update objects on platforms
         updatePlatforms(ctx);
         
         // Do collision detection
         detectCollisions(ctx);

         // Game over if the player has lost all the lifes
         if(m_player -> lives() <= 0)
            die("THE MEANIES GOT YOU!", true);
      }
      if(m_status == GameEnding && !m_gameOverSound -> isPlaying())
      {
         endGame(ctx);
      }
   } 
Ejemplo n.º 29
0
Archivo: cA1b.c Proyecto: azend/School
//
// FUNCTION : startGame
// DESCRIPTION :
// This function declares and initializes some values and then starts the game loop
// PARAMETERS :
// void : void
// RETURNS :
// void : void
//
void startGame (void) {
	int result;

	struct briefcase briefcases [NUM_BRIEFCASES];
	populateBriefcases(briefcases);

	result = gameLoop(briefcases);
	
	endGame(result);
}
Ejemplo n.º 30
0
void Game::timerEvent(QTimerEvent *)
{
    moveBall();
    repaint();

    if (leftScore >= 10 || rightScore >= 10)
    {
        endGame();
    }
}