void GameEngine::startNewGame() { if(m_lives->getLives() && !m_player) { if(m_gamequeue->empty()) { cleanup(); showGameWon(); } else { if(!gameLost()) { m_mtx = new CubeMatrix; m_mtx->fillLevel(*m_gamequeue->back()); } m_player = new Racket(100,520); m_ball = new Ball(120,400,qreal(3),qreal(-M_PI/2)); m_player->setFlag(QGraphicsItem::ItemIsFocusable); m_player->setFocus(); setGameLost(false); } } }
int start_campaign() { int i, j; int gameresult = 0, endcampaign = 0; char roundmessage[10]; char endtext[2][MAX_LINEWIDTH] = {N_("Congratulations! You win!"), " "}; fprintf(stderr, "Entering start_campaign()\n"); for (i = 0; i < NUM_STAGES; ++i) { fprintf(stderr, "Stage %s\n", stagenames[i]); briefPlayer(i); for (j = 1; j <= NUM_ROUNDS; ++j) { fprintf(stderr, "Round %d\n", j); //read in settings read_named_config_file(local_game, "campaign/campaign"); readStageSettings(i); readRoundSettings(i, j); Opts_SetKeepScore(0); snprintf(roundmessage, 10, "%s %d", N_("Round"), j); game_set_start_message(roundmessage, "", "", ""); DEBUGCODE(debug_setup) { MC_PrintMathOptions(local_game, stdout, 0); } //play! fprintf(stderr, "Starting game...\n"); gameresult = comets_game(local_game); //move on if we've won, game over if not if (gameresult == GAME_OVER_WON) ; else if (gameresult == GAME_OVER_LOST) { showGameOver(); endcampaign = 1; } else if (gameresult == GAME_OVER_ERROR) { DEBUGMSG(debug_game, "Error!\n"); endcampaign = 1; } #ifndef TESTING_CAMPAIGN else if (gameresult == GAME_OVER_ESCAPE) { DEBUGMSG(debug_game, "hit escape\n"); endcampaign = 1; } #endif else { fprintf(stderr, "gameresult = %d\n", gameresult); endcampaign = 0; } if (endcampaign) return 0; } //if we've beaten the last stage, there is no bonus, skip to win sequence if (i == NUM_STAGES - 1) { showGameWon(); break; } /* //bonus round readStageSettings(i); readRoundSettings(i, -1); game_set_start_message("Bonus", "", "", ""); game(); */ } scroll_text(endtext, screen->clip_rect, 3); return 0; }