void resetGameLoadMapAddActors( GameModel & game, PathGraph & pathgraph, GameView & view, GameViewSound & sound, ActorControllerKeyboard * & keyboardController, std::map< std::string, ActorControllerAI * > & aiControllers, std::map< std::string, float > & globalVariables, float gametime, const std::string & filename ) { // delete ai controllers for( std::map< std::string, ActorControllerAI * >::iterator iter = aiControllers.begin( ); iter != aiControllers.end( ); iter++ ) { delete iter->second; } aiControllers.clear( ); // reset game resetGame( game, pathgraph, view, sound ); setGameVars( game, globalVariables ); // load map loadMap( game, pathgraph, view, sound, globalVariables, filename ); view.initBrushTextures( ); // add players //addPlayer( game, keyboardController, globalVariables, gametime, "Player" ); addActor( game, keyboardController, globalVariables, gametime, "Player" ); for( int i = 0; i < 3; i++ ) { aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ] = new ActorControllerAI( &game, pathgraph ); //addAI( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) ); addActor( game, aiControllers[ "AI-" + std::string( 1, (char)( i + 49 ) ) ], globalVariables, gametime, "AI-" + std::string( 1, (char)( i + 49 ) ) ); } view.setCamera( &game.getActors( ).front( ) ); sound.setCamera( &game.getActors( ).front( ) ); }
/* * Load City and do setup for Lincity NG. */ bool loadCityNG( std::string filename ){ if( file_exists( const_cast<char*>( filename.c_str()) ) ){ load_city(const_cast<char*>(filename.c_str())); update_avail_modules(0); GameView* gv = getGameView(); if( gv ){ gv->readOrigin(); } return true; } return false; }
Q_DECL_EXPORT int main(int argc, char** argv) { QApplication app(argc, argv); GameView view; #ifdef HARMATTAN view.showFullScreen(); #else view.show(); #endif return app.exec(); }
void FormHome::OnActionPerformed(const Control& source, int actionId) { // Interactions for video launching buttons switch (actionId) { case ActionPlay:{ GameView* pGameForm = new GameView; if (!pGameForm) break; if (!pGameForm->Initialize()) break; //Stop sound // _pSoundThread->Stop(); // _pSoundThread->Exit(); PushForm(pGameForm); pGameForm->startTimer(); } break; // case ActionScore:{ // FormScore* pScoreForm = new FormScore; // if (!pScoreForm) break; // if (!pScoreForm->Initialize()) // break; // PushForm(pScoreForm); // } // break; // // case ActionHelp:{ // FormHelp* pHelpForm = new FormHelp; // if (!pHelpForm) break; // if (!pHelpForm->Initialize()) // break; // PushForm(pHelpForm); // } // break; // // case ActionCredits:{ // FormCredits* pCreditsForm = new FormCredits; // if (!pCreditsForm) break; // if (!pCreditsForm->Initialize()) // break; // PushForm(pCreditsForm); // } // break; default: BaseController::OnActionPerformed(source, actionId); break; } }
AIPlayer::AIPlayer(int level, GameView &targetView) : GamePlayer(targetView) { internalGrid = NULL; decisionMade = 0; shouldRedecide = false; lastNumberOfBadFlobos = 0; totalNumberOfBadFlobos = 0; attachedGame = targetView.getAttachedGame(); objective = nullBinom; lastLineSeen = FLOBOBAN_DIMY+1; currentCycle = 0; readyToDrop = false; params.realSuppressionValue = 1; params.potentialSuppressionValue = 3; params.criticalHeight = 10; params.columnScalar[5] = 1; params.columnScalar[0] = 1; params.columnScalar[1] = 1; params.columnScalar[2] = 1; params.columnScalar[3] = 1; params.columnScalar[4] = 1; params.columnScalar[5] = 1; params.rotationMethod = 0; // negative (right), null (shortest), positive(left) params.fastDropDelta = FLOBOBAN_DIMY; // flobo height relative to column height before fast drop params.thinkDepth = 2; params.speedFactor = level>0?level:1; this->level = level; }
void resetGame( GameModel & game, PathGraph & pathgraph, GameView & view, GameViewSound & sound ) { view.clearObjects( ); view.uninitActorText( ); view.uninitBrushes( ); sound.uninitActors( ); game = GameModel( ); pathgraph = PathGraph( ); game.addObserver( &view ); view.setGame( &game ); view.setThirdPerson( ); game.addObserver( &sound ); sound.setGame( &game ); }
StatsBoard::StatsBoard(GameView& gameView) : Displayable(gameView), statsManager(StatsManager::getInstance()) { float viewX(WINDOW_WIDTH); float viewY(WINDOW_HEIGHT); background.setSize(sf::Vector2f(viewX, viewY)); background.setFillColor(sf::Color(0x00, 0x00, 0x00, 0xE0)); background.setPosition(0, 0); gameView.addView(ViewLayer::STATS, this); }
int main() { srand((unsigned) time(NULL)); GameModel *model = new GameModel(); GameView *view = new GameView(); view->setModel(model); view->presentation(); int message; int reponse; reponse = model->saisieChoix(); cout << endl; while(true){ switch(reponse) { case 0: view->retourMenu(); message = model->saisieChoix(); while(message == 0) { if(model->getEndGame() == true) { view->affiche(); view->answer_move(model); model->direction(model->get_answer_move()); } else { message = model->rejouerPartie(); } } if(message == 1) return EXIT_SUCCESS; break; case 1: return EXIT_SUCCESS; break; case 2: view->affichageScore(); // affichage du score au menu si demandé view->retourMenu(); cin >> reponse; break; } } delete view; delete model; return EXIT_SUCCESS; }
/** * Either create selected random terrain or load a scenario. **/ void MainMenu::newGameStartButtonClicked(Button* ) { if( mFilename.empty() ){ // std::cout << "nothing selected\n"; return; } getSound()->playSound( "Click" ); int with_village = (getCheckButton(*currentMenu,"WithVillage")->state == CheckButton::STATE_CHECKED)?1:0; if( baseName == "RiverDelta" ){ new_city( &main_screen_originx, &main_screen_originy, with_village ); GameView* gv = getGameView(); if( gv ){ gv->readOrigin(); } quitState = INGAME; running = false; } else if( baseName == "DesertArea" ){ new_desert_city( &main_screen_originx, &main_screen_originy, with_village ); GameView* gv = getGameView(); if( gv ){ gv->readOrigin(); } quitState = INGAME; running = false; } else if( baseName == "TemperateArea" ){ new_temperate_city( &main_screen_originx, &main_screen_originy, with_village ); GameView* gv = getGameView(); if( gv ){ gv->readOrigin(); } quitState = INGAME; running = false; } else if( baseName == "SwampArea" ){ new_swamp_city( &main_screen_originx, &main_screen_originy, with_village ); GameView* gv = getGameView(); if( gv ){ gv->readOrigin(); } quitState = INGAME; running = false; } else { if( loadCityNG( mFilename ) ){ strcpy (given_scene, baseName.c_str()); quitState = INGAME; running = false; } } mFilename = "empty"; //don't erase scenarios later }
Death::Death(GameView& view, bool isMute) : Displayable(view) { float viewX = gameView.getSizeX(); float viewY = gameView.getSizeY(); rect.setSize(sf::Vector2f(viewX, viewY)); rect.setFillColor(sf::Color(0x00, 0x00, 0x00, 0xFF)); rect.setPosition(0, 0); wokeUp.setString("You woke up... "); wokeUp.setFont(globalFont); wokeUp.setCharacterSize(CHAR_SIZE); float midX = viewX/2; float midY = viewY/2; texture.loadFromFile(DREAMOVER); elo.setTexture(texture); float midEloX = (elo.getLocalBounds().width)/2; float midEloY = (elo.getLocalBounds().height)/2; float botElo = midY + midEloY; elo.setPosition(midX - midEloX, midY - midEloY); wokeUp.setPosition(midX - wokeUp.getLocalBounds().width/2, botElo + INTERSPACE); if (!music.openFromFile(MUSIC_PATH + "/" + MUSIC)) { // TODO Handle error } else { music.setLoop(true); if (!isMute) { music.play(); } } view.addView(ViewLayer::DEATH, this); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); GameView gameView; gameView.show(); return app.exec(); }
int main() { GameView game; game.run(); }
int main(int argc, char *argv[]) { // Register all QML mapped C++ classes qmlRegisterType<GameScene>("Nanoparticles", 1, 0, "GameScene"); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); qDebug() << "Enabling settings"; QCoreApplication::setOrganizationName("Dragly"); QCoreApplication::setOrganizationDomain("dragly.org"); QCoreApplication::setApplicationName("Nanoparticles"); GameApplication gameApplication(argc, argv); qDebug() << "Starting view"; GameView view; gameApplication.setGameView(&view); // Font loading qDebug() << "Starting database"; if(!QFontDatabase::addApplicationFont(":/fonts/novasquare/NovaSquare.ttf")) { qWarning() << "Could not load Nova font!"; } qDebug() << "font loaded"; gameApplication.setFont(QFont("Nova Square")); //#if defined(Q_WS_MAEMO_5) || defined(Q_OS_LINUX) #ifndef NO_OPENGL qDebug() << "Using OpenGL"; QGLWidget glwidget; // IMPORTANT: Disabling this makes animations with images sluggish. // Disable only if enteriely necessary, and try to find another option to draw smooth animations first view.setViewport(&glwidget); #else qDebug() << "Not using OpenGL"; #endif //#endif qDebug() << "setViewport"; #if defined(Q_WS_S60) qDebug() << "Is Symbian!"; view.showFullScreen(); #elif defined(Q_WS_MAEMO_5) qDebug() << "Is Maemo!"; view.showFullScreen(); #elif defined(OS_IS_HARMATTAN) qDebug() << "Is MeeGo!"; view.showFullScreen(); #elif defined(OS_IS_ANDROID) qDebug() << "Is Android!"; view.showFullScreen(); #elif defined(OS_IS_DESKTOP_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_WIN) #if defined(OS_IS_DESKTOP_LINUX) qDebug() << "Is Destkop Linux"; #elif defined(Q_OS_MAC) qDebug() << "Is Mac!"; #elif defined(Q_OS_WIN) qDebug() << "Is Windows!"; #endif QSettings settings; int viewMode = settings.value("viewMode", 0).toInt(); if(viewMode == GameScene::ViewNormal) { view.showNormal(); } else { view.showFullScreen(); } #else qDebug() << "Is some unknown OS!"; if(viewMode == 0) { view.showNormal(); } else { view.showFullScreen(); } #endif return gameApplication.exec(); }
/* * get Data form Lincity NG and Save City */ void saveCityNG( std::string newFilename ){ GameView* gv = getGameView(); if( gv ){ gv->writeOrigin(); } save_city(const_cast<char*>( newFilename.c_str() ) ); }
/* Static routine */ void GameView::startThread(void *param) { GameView *game = (GameView*)param; game->runThread(); }