int typeGame(int lev, int p_m, int type, int change) { switch (type) { case 0: //Mode of the game with levels { initMap(); if (change){ //If the player pass the next level, move to the next level. lev++; mappingLevel(lev);} else mappingLevel(lev); return lev; break; } case 1: //Practice mode { initMap(); modePract(p_m); //Initialize the mode of the practice return 0; break; } } return 0; }
Serializer::Serializer() { initObjList(); initMap(_objList, _addressMap); initOctmoList(); initMap(_octmoList, _octmoMap); initOcatoList(); initMap(_ocatoList, _ocatoMap); }
bool Level6::initWithDifficulty(int difficulty) { if ( !Layer::init() ) { return false; } SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_level6-hd.plist"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_level6_2-hd.plist"); setLevel(6); this->difficulty = difficulty; initMap(); std::vector<Point> points; points.push_back(Point(40,360)); points.push_back(Point(40,610)); points.push_back(Point(756,940)); points.push_back(Point(1145,560)); addWaveProgressBars(points); waveFlags.at(0)->restartWaveFlag(); waveFlags.at(1)->restartWaveFlag(); waveFlags.at(2)->restartWaveFlag(); waveFlags.at(3)->restartWaveFlag(); SoundManager::playJungleBattle(); return true; }
int main (int argc, const char * argv[]) { clock_t timer; struct hashMap* hashTable; int tableSize = 1000; timer = clock(); initMap(hashTable,tableSize); FILE* dictionary; loadDictionary(dictionary,hashTable); timer = clock() - timer; printf("Dictionary loaded in %f seconds\n", (float)timer / (float)CLOCKS_PER_SEC); char* word = (char*)malloc(256*sizeof(char)); int quit=0; while(!quit){ printf("Enter a word: "); scanf("%s",word); /* ... spell checker code goes here ... ... You write this ... */ /* Don't remove this. It is used for grading*/ if(strcmp(word,"quit")==0) quit=!quit; } free(word); return 0; }
const NameMap& CustomerType::nameMap() const { static NameMap s_nameMap; static bool initialized = false; static const QStringList NAMES = types.split(","); return initMap(s_nameMap, NAMES, initialized); }
void PiecesTable::readConfig() { Config cfg("Fifteen"); cfg.setGroup("Game"); QStringList map = cfg.readListEntry("Map", '-'); _randomized = cfg.readBoolEntry( "Randomized", FALSE ); _image = cfg.readEntry( "Image", QString::null ); int rows = cfg.readNumEntry( "Rows", 4 ); int cols = cfg.readNumEntry( "Cols", 4 ); uint items= rows*cols; setNumRows( rows ); setNumCols( cols ); initMap(); /* if we've more items than 'stones' don't restore the state */ if ( items > map.count() ) return; uint i = 0; for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) { _map[i] = (*it).toInt(); i++; if ( i > items ) break; } }
/* Construct a random dungeon */ void buildMap() { int ii; int jj; mapTopX = 0; mapTopY = 0; initMap(); generations = 1; fillprob = 35; params = params_set = (generation_params*)malloc( sizeof(generation_params) * generations); params->r1_cutoff = 24; params->r2_cutoff = 5; params->reps = 1; params++; params->r1_cutoff = 20; params->r2_cutoff = 3; params->reps = 1; params++; for(ii=0; ii<generations; ii++) { params = ¶ms_set[ii]; for(jj=0; jj<params->reps; jj++) generation(); } free(params); free(params_set); }
int main( int argc, char *argv[] ) { char WAR[61]; int i, numCases ; FILE *fin ; if ( argc != 2 ) { printf( "Usage: allYourBase file_name_with_test_cases\n" ) ; return 0 ; } fin = fopen( argv[1], "r" ) ; /* Get number of test cases */ fscanf( fin, "%d", &numCases ) ; /* Iterate through each string/test case */ for ( i = 0 ; i < numCases ; i++ ) { initMap(); fscanf( fin, "%s", WAR ) ; printf( "Case #%d: %lld\n", i+1, findLowestNumberOfSeconds(WAR)) ; } return 0 ; }
// Main game function void run() { // Initialize the map initMap(); running = true; while (running) { // If a key is pressed if (_kbhit()) { // Change to direction determined by key pressed changeDirection(_getch()); } // Upate the map update(); // Clear the screen clearScreen(); // Print the map printMap(); // wait 0.5 seconds Sleep(500); } // Print out game over text std::cout << "\t\t!!!Game over!" << std::endl << "\t\tYour score is: " << food; // Stop console from closing instantly std::cin.ignore(); }
bool Level12::initWithDifficulty(int difficulty) { if ( !Layer::init() ) { return false; } SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_Level12-hd.plist"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_Level12_2-hd.plist"); setLevel(12); this->difficulty = difficulty; initMap(); std::vector<Point> points; points.push_back(Point(450,800)); points.push_back(Point(40,300)); points.push_back(Point(1091,710)); addWaveProgressBars(points); waveFlags.at(0)->restartWaveFlag(); waveFlags.at(1)->restartWaveFlag(); waveFlags.at(2)->restartWaveFlag(); SoundManager::playDesertBattle(); return true; }
ColorMap::ColorMap(const QString &newName, QObject *parent) : QObject(parent) { _name = newName; _values = new uint[MapElements]; initMap(); }
void MAP::printMap(Point robot) { int robotRow, robotCol; realToMap(robot, robotRow, robotCol); for (int i = 0; i < MAP_WIDTH; i++) { for (int j = 0; j < MAP_HEIGHT; j++) { if (i == robotRow && j == robotCol) std::cout << "R"; else { switch (_map[i][j]) { case FREE: std::cout << " "; break; case OCCUPIED: std::cout << "*"; break; case UNKNOWN: std::cout << "?"; break; default: initMap(); } } } std::cout << std::endl; } std::cout << std::endl; std::cout << std::endl; std::cout << std::endl; }
void FullpipeEngine::restartGame() { _floaters->stopAll(); clearGlobalMessageQueueList(); clearMessages(); initObjectStates(); if (_scene2) { _scene2->getAniMan(); _scene2 = 0; } if (_currentScene) { _gameLoader->unloadScene(_currentScene->_sceneId); _currentScene = 0; } _gameLoader->restoreDefPicAniInfos(); getGameLoaderInventory()->clear(); getGameLoaderInventory()->addItem(ANI_INV_MAP, 1); getGameLoaderInventory()->rebuildItemRects(); initMap(); if (_flgPlayIntro) { _gameLoader->loadScene(SC_INTRO1); _gameLoader->gotoScene(SC_INTRO1, TrubaUp); } else { _gameLoader->loadScene(SC_1); _gameLoader->gotoScene(SC_1, TrubaLeft); } }
void gameInitial() { int i; initMap(map); drawInfo(global.score, global.life); pacman.mapX = 14; pacman.mapY = 18; pacman.screenX = 14 * UNIT + UNIT / 2 + OFFSET; pacman.screenY = 18 * UNIT + UNIT / 2 + OFFSET; pacman.dir = UP; pacman.speed = 1.2; drawPacman((int)pacman.screenX, (int)pacman.screenY, pacman.dir); for (i = 0; i < 3; i++) { ghost[i].mapX = 12 + i * 2; ghost[i].mapY = 16; ghost[i].screenX = mapToscreen(ghost[i].mapX) + UNIT / 2; ghost[i].screenY = mapToscreen(16); ghost[i].dir = UP; ghost[i].burst = 0; ghost[i].speed = 0.9; drawGhost(i, (int)ghost[i].screenX, (int)ghost[i].screenY, ghost[i].dir, ghost[i].burst); } ghost[3].mapX = 14; ghost[3].mapY = 12; ghost[3].screenX = mapToscreen(ghost[3].mapX); ghost[3].screenY = mapToscreen(12) + UNIT / 2; ghost[3].dir = LEFT; ghost[3].burst = 0; ghost[3].speed = 0.4; drawGhost(3, (int)ghost[3].screenX, (int)ghost[3].screenY, ghost[3].dir, ghost[3].burst); }
int main(void){ char* map = initMap(); banner(map); int input = 0; int turn; for(turn=5; turn != 0; turn-- ){ printf("Dein Zug: "); if(scanf("%d", &input) <= 0){ printf("\nFehler bei der Eingabe!\n"); while(getchar() != '\n'); turn++; continue; } if(setMap(map, input) == 0){ if(check(map) != 0) break; outMap(map); printf("Gegner ist am Zug:\n"); setNPC(map); outMap(map); if(check(map) != 0) break; } else{ turn++; } } printf("Der Sieger ist...\n"); //Das kann man bestimmt auch besser machen.. int result = check(map); if(result == 0) printf("Niemand\n"); else if(result == 1) printf("Der Spieler\n"); else if(result == 2) printf("Der Computer\n"); free(map); writeRecord(result); return 0; }
int main(int argc, char** argv) { //Generate map foundation short int map[MAPSIZE][MAPSIZE]; int branch_chance = 50; initMap(map); createMainPath(map); createBranches(map, branch_chance); printMap(map); system("pause"); /* Standard GLUT initialization */ //glutInit(&argc,argv); /*glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(700,700); glutInitWindowPosition(50,50); glutCreateWindow("War Games Scene"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(myKey);*/ //myinit(); //glutMainLoop(); /* enter event loop */ }
Register::Register(std::shared_ptr<Memory> mem) { for (int i = 0; i < NUM_OF_REG; i++) { registerList[i] = new int{ 0 }; // init registers } initMap(); ram = std::move(mem); }
// on "init" you need to initialize your instance bool GameFatherLayer::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); initMap(); initUI(); initRole(); initComponents(); return true; }
void updateTimer(int tid){ int i; static int cou=0; switch(tid){ case 0: stage=0; keyTimer(tid); mapTimer(tid); break; case 1: stage=1; keyTimer(tid); menuTimer(tid); break; case 2: cou++; stage=3; menuTimer(tid); if (cou==30) { cancelTimer(2); startTimer(0,10); level=1; initMap(1); cou=0; for(i=0;i<=buttonCount;i++) { allButton[i].up=1; } } } }
bool Level10::initWithDifficulty(int difficulty) { if ( !Layer::init() ) { return false; } SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_level10-hd.plist"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprite_level10_2-hd.plist"); setLevel(10); this->difficulty = difficulty; initMap(); MyAnimation::getInstance()->init_BossCanibal(); std::vector<Point> points; points.push_back(Point(610,710)); points.push_back(Point(650,710)); addWaveProgressBars(points); waveFlags.at(0)->restartWaveFlag(); waveFlags.at(1)->restartWaveFlag(); Vector<SpriteFrame*> animFrames1; SpriteFrame* frame1=NULL; for (int i = 1; i <= 31; i++) { frame1 = SpriteFrameCache::getInstance()->getSpriteFrameByName(String::createWithFormat("Stage10_Tower_00%02d.png",i)->getCString()); if(frame1!=nullptr) animFrames1.pushBack(frame1); } AnimationCache::getInstance()->addAnimation(Animation::createWithSpriteFrames(animFrames1, 0.04f),"level_stage"); SoundManager::playJungleBattle(); return true; }
void TilesetDialog::tick(const float dt) { Container::tick(dt); if (_sl_tilesets->changed()) { _sl_tilesets->reset(); if (!_sl_tilesets->empty()) set(_sl_tilesets->get()); } std::string tileset = _add_tileset->getTileset(); if (!tileset.empty()) { LOG_DEBUG(("adding tileset!")); Map->addTileset(tileset); initMap(); _tileset_added = true; } if (_current_tileset == NULL || hidden()) return; GET_CONFIG_VALUE("editor.scrolling-speed", int, ss, 500); _pos += _vel * (ss * dt); if (_pos.x + _w > _current_tileset->get_width()) _pos.x = _current_tileset->get_width() - _w; if (_pos.y + _h > _current_tileset->get_height()) _pos.y = _current_tileset->get_height() - _h; if (_pos.x < 0) _pos.x = 0; if (_pos.y < 0) _pos.y = 0; //LOG_DEBUG(("%g %g", _pos.x, _pos.y)); }
void MainWindow::setupUI() { ui->statusBar->addWidget(&statusLabel); ui->interestsListView->setModel( &interestsModel ); //enum Interest { SIGHT, CULTURE, PARK, ENTERTAINMENT }; interestsModel.appendRow(new SelectionItem("Достопримечательности")); interestsModel.appendRow(new SelectionItem("Культура")); interestsModel.appendRow(new SelectionItem("Парки")); interestsModel.appendRow(new SelectionItem("Развлечения")); ui->transportListView->setModel( &transportModel ); //enum Transport {CAR, UNDERGROUND, BUS, TROLLEYBUS, TRAM, TAXI, FOOT}; transportModel.appendRow(new SelectionItem("Автомобиль")); transportModel.appendRow(new SelectionItem("Метро")); transportModel.appendRow(new SelectionItem("Автобус")); transportModel.appendRow(new SelectionItem("Троллейбус")); transportModel.appendRow(new SelectionItem("Трамвай")); transportModel.appendRow(new SelectionItem("Маршрутка")); transportModel.appendRow(new SelectionItem("Пешком")); ui->sortTypeComboBox->addItem("По времени"); ui->sortTypeComboBox->addItem("По стоимости"); ui->createPlaceButton->setEnabled(false); ui->createRouteButton->setEnabled(false); ui->removeButton->setEnabled(false); ui->routesTableWidget->setColumnCount(5); QStringList horizontalLabels; horizontalLabels.append("Начало"); horizontalLabels.append("Конец"); horizontalLabels.append("Стоимость"); horizontalLabels.append("Время"); horizontalLabels.append("Действия"); ui->routesTableWidget->setHorizontalHeaderLabels(horizontalLabels); fillPlaces(ui->startList); fillPlaces(ui->finishList); connect(&placeDialog,SIGNAL(accepted()),ui->mapWidget,SLOT(createPlace())); connect(&placeDialog,SIGNAL(rejected()), this, SLOT(cancelCreatingPlace())); connect(&placeDialog,SIGNAL(accepted()),this,SLOT(onPlaceDataEntered())); connect(&routeDialog,SIGNAL(accepted()),ui->mapWidget,SLOT(createRoute())); connect(&routeDialog,SIGNAL(rejected()), this, SLOT(cancelCreatingRoute())); connect(&routeDialog,SIGNAL(accepted()),this,SLOT(onRouteDataEntered())); connect(&saveDialog,SIGNAL(accepted()),this,SLOT(save())); connect(&saveDialog,SIGNAL(rejected()),this,SLOT(cancel())); connect(ui->mapWidget,SIGNAL(placeCreated(double,double)),this,SLOT(onPlaceCreated(double,double))); connect(ui->mapWidget,SIGNAL(routeCreated(int,int)),this,SLOT(onRouteCreated(int,int))); connect(ui->mapWidget,SIGNAL(firstPlaceSelected()),this,SLOT(onFirstPlaceSelected())); connect(ui->mapWidget,SIGNAL(secondPlaceSelected()),this,SLOT(onSecondPlaceSelected())); connect(ui->mapWidget, SIGNAL(mapReady()), this, SLOT(initMap())); connect(ui->mapWidget, SIGNAL(elementRemoved()), this, SLOT(onElementRemoved())); connect(ui->editMapButton, SIGNAL(clicked()), this, SLOT(editMode())); connect(ui->searchRoutesButton, SIGNAL(clicked()), this, SLOT(runRouteSearching())); }
void PiecesTable::randomizeMap() { initMap(); _randomized = true; // find the free position int cols = numCols(); int rows = numRows(); int pos = _map.find( cols*rows -1 ); int move = 0; while ( move < 333 ) { int frow = pos / cols; int fcol = pos - frow * cols; // find click position int row = rand()%rows; int col = rand()%cols; // sanity check if ( row < 0 || row >= rows ) continue; if ( col < 0 || col >= cols ) continue; if ( row != frow && col != fcol ) continue; move++; // rows match -> shift pieces if(row == frow) { if (col < fcol) { for(int c = fcol; c > col; c--) { _map[c + row * cols] = _map[ c-1 + row *cols]; } } else if (col > fcol) { for(int c = fcol; c < col; c++) { _map[c + row * cols] = _map[ c+1 + row *cols]; } } } // cols match -> shift pieces else if (col == fcol) { if (row < frow) { for(int r = frow; r > row; r--) { _map[col + r * cols] = _map[ col + (r-1) *cols]; } } else if (row > frow) { for(int r = frow; r < row; r++) { _map[col + r * cols] = _map[ col + (r+1) *cols]; } } } // move free cell to click position _map[pos=(col + row * cols)] = rows*cols-1; } repaint(); }
RoomManager::RoomManager() { srand(time(NULL)); addPlayerMutex = PTHREAD_MUTEX_INITIALIZER; MAX_ONE_TYPE_ROOMS = 10; initRooms(); initMap(); }
DisplayEnumerator::DisplayEnumerator(string configFileName){ if(_displaySettingsConfig.loadFile(configFileName)){ _dispTypeMap = initMap(); readDisplayPositions(); }else{ cout<<"Unable to load the config file."<<"\n"; } }
void Stage::initialize(){ vector<int> area; FileStream::load("data/data.dat", area); stringstream ss; ss << area[1] + 1; initID(); initMap(ss.str()); }
void IS::GameObject::Component::Rule::initialisation() { /*IS::GameObject::GameObject *Splash = new IS::GameObject::GameObject(_sceneManager); Ogre::ParticleSystem* particleSystem = _scene->getSceneManager()->getSceneManager()->createParticleSystem("particle3", "SplashScreen"); Splash->getSceneNode()->getParentSceneNode()->attachObject(particleSystem); */ initMap(); }
int main(int argc, char** argv) { GtkWidget* w; GtkWidget* box; GtkWidget* p; GtkWidget* f; GtkWidget* menu; GtkWidget* item; GtkWidget* sub; gtk_init(&argc, &argv); // creates the window w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(w), "ev.view"); gtk_window_resize(GTK_WINDOW(w), 640, 480); box = gtk_vbox_new(FALSE, 0); // set menues menu = gtk_menu_bar_new(); gtk_box_pack_start(GTK_BOX(box), menu, FALSE, TRUE, 0); // File item = gtk_menu_item_new_with_label("File"); sub = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), sub); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); newMenuItem(sub, "Open data...", G_CALLBACK(menuOpenData), w); itemRecons = newMenuItem(sub, "Open reconstruction...", G_CALLBACK(menuOpenRec), w); gtk_widget_set_sensitive(GTK_WIDGET(itemRecons), FALSE); newMenuItem(sub, "Quit", G_CALLBACK(menuQuit), NULL); // Map item = gtk_menu_item_new_with_label("Map"); sub = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), sub); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); newMenuItem(sub, "Open raster...", G_CALLBACK(menuOpenRaster), NULL); // Layout p = gtk_hpaned_new(); gtk_widget_set_size_request(p, 100, -1); f = gtk_frame_new(NULL); gtk_paned_pack1(GTK_PANED(p), f, TRUE, FALSE); gtk_widget_set_size_request(f, 50, -1); initTree(f); f = gtk_frame_new(NULL); gtk_paned_pack2(GTK_PANED(p), f, TRUE, FALSE); gtk_widget_set_size_request(f, 50, -1); initMap(f); gtk_box_pack_start(GTK_BOX(box), p, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(w), box); gtk_widget_show_all(w); gtk_widget_add_events(w, GDK_KEY_PRESS_MASK); g_signal_connect(G_OBJECT(w), "key_press_event", G_CALLBACK(keyPress), w); gtk_main(); return 0; }
int main (int argc, char* argv[]) { if (!loadMapFromFile ("maps/level1.map")) { printf ("Can't locate map!"); } initGUI(); initMap(); initPlayer(); SDL_Event e; int quit = 0; int start_time; int urd_time; int wait_time; int target_time = 1000/FPS; while (!quit) { start_time = SDL_GetTicks(); while (SDL_PollEvent (&e)) { if (e.type == SDL_QUIT) { quit = 1; } else { player->left = 0; player->right = 0; } processInput (); } clearScreen(); updatePlayer (player); renderBackground(); renderMap(); renderPlayer (player); draw(); urd_time = (SDL_GetTicks() - start_time); wait_time = target_time - urd_time; SDL_Delay (wait_time); } destroyGUI(); deletePlayer (player); return 0; }
ToneMap::ToneMap(IPFConfiguration &config) { num_tones_ = COLOR_DEPTH; setP1Params(config.ToneMapBrightSigma); setP2Params(config.ToneMapMiddleMuLower, config.ToneMapMiddleMuUpper); setP3Params(config.ToneMapDarkSigma, config.ToneMapDarkMu); setPWeigths(config.ToneMapBrightWeight, config.ToneMapMiddleWeight, config.ToneMapDarkWeight); initMap(); }