/*-------------------------------------------------------------------------------------------- -- FUNCTION: createBaseScenery -- -- DATE: April 7th, 2016 -- -- DESIGNERS: Jaegar Sarauer -- -- REVISIONS: NONE -- -- PROGRAMMERS: Jaegar Sarauer -- -- INTERFACE: void Map::createBaseScenery () -- -- RETURNS: void -- -- NOTES: This will create a set amount if points to originate grass, and a size of -- origination. then fan out with a random diffusion level until it meets its -- same value. Imagine an elevation map with the id's of the tile meaning -- the height. -- The purpose of this is to give the effects of different colored grass on the -- walkable portions of the map. ------------------------------------------------------------------------------------------*/ void Map::createBaseScenery () { //how many origins of grass there will be int origins = 3; //size of the initial dot int size = (rand () % 4) + 1; //amount of random paths to walk out from origin to make origin point int walks = 0; int tmpSize = size; while (tmpSize > 0) walks += 4 * tmpSize--; //every n cycles, the value of the grass will decrease int diffusion = 2; //this 2d array is a result of one cycle, it is saved to the tmp array after each process int ** localTemp = new int*[mapWidth]; for (int i = 0; i < mapWidth; ++i) localTemp[i] = new int[mapHeight]; resetMap (localTemp, 0); //When a -1 is read as a value anywhere on the map, it isnt done elevation calculations bool flagIsNull = true; for (int i = 0; i < origins; i++) { //pick a random point to place the grass origin int x = rand () % mapWidth; int y = rand () % mapHeight; tempLayer[x][y] = 1; } while (flagIsNull) { flagIsNull = false; for (int x = 0; x < mapWidth; x++) for (int y = 0; y < mapHeight; y++) if (getNeighbourConditional (x, y, &Map::surroundingHeightsCount) >= localTemp[x][y]) { localTemp[x][y] += (rand () % 10 <= getNeighbourConditional (x, y, &Map::surroundingHeightsCount)) ? 1 : 0; } for (int x = 0; x < mapWidth; x++) for (int y = 0; y < mapHeight; y++) { tempLayer[x][y] += localTemp[x][y]; if (tempLayer[x][y] == -1) flagIsNull = true; } //drawMap (tempLayer); resetMap (localTemp, 0); } delete[] localTemp; }
void Mapping::keepRendering() { resetMap(); while(run) { if(lasers != NULL) { lasers->clear(); delete lasers; } mRobot->readingSensors(); lasers = mRobot->getLaserRanges(); sonares = mRobot->getSonarRanges(); sensores = sonares; ArSensorReading ar = sensores->at(0); //Apenas para pegar as informações de posição do robo no momento da tomada de informações. updateRoboPosition(ar.getXTaken(),ar.getYTaken(),ar.getThTaken()); switch(this->technique) { case MappingTechnique::DeadReckoning: calculateMapDeadReckoning(); break; case MappingTechnique::BAYES: calculateMapBayes(); break; case MappingTechnique::HIMM: calculateMapHIMM(); break; } ArUtil::sleep(33); } thread->exit(); thread->wait(); }
void MainWindow::resetMap() { qDebug() << "In reset map"; //Initialize all the blocks for (int i=0; i<10; i++) { for (int j=0; j<10; j++) { b[i][j]->number=0; } } for(int i=0; i<10; i++)//row { for (int j=0; j<10; j++)//column { b[i][j]->setNumber(); b[i][j]->setButtonPic(); if (j>=2 && (b[i][j]->number == b[i][j-2]->number) && (b[i][j]->number == b[i][j-1]->number)) {j--;} if (i>=2 && (b[i][j]->number == b[i-2][j]->number) && (b[i][j]->number == b[i-1][j]->number)) {j--;} } } if (cannotPlay()==true){resetMap();} }
bool Mapper::resetMapCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res) { res.success = true; res.message = "Map reset successfully."; resetMap(); ROS_INFO_STREAM("Reset map and percent mowed."); return true; }
void Game_Manager::CreationMonde5(int difficulter) { //un chemin de lumiere le reste du vide resetMap(); int current = 3, precedent; for (int x = 5; x < MAXX; x++) { precedent = current; current = modifcourant(current); for (int y = 0; y < MAXY; y++) { if (y == current) { if (y % 3 != 0) { Map[y][x].setLight(3); } } else if (y != precedent) { if (rand() % 3 != 0) { } else { //vide } } else { if (rand() % 2 == 0) { Map[y][x].setMob(1 + rand() % 8); } else { //vide } } } } Lumiere(); }
void VirtualWallLayer::updateWalls() { resetMap(0, 0, getSizeInCellsX(), getSizeInCellsY()); for (std::map<std::string, WallInfo>::iterator it=walls.begin(); it!=walls.end(); ++it) { drawWallLine((int) (*it).second.x1, (int) (*it).second.y1, (int) (*it).second.x2, (int) (*it).second.y2); } }
static void scan(){ int i = MAC_DRIVE_INDEX; if(g_loaded[i]) return; resetMap(i); scanUnix(genRootFileEntry(i),i); g_loaded[i]=1; save_db(i); printf("Scan drive %c finished.\n",i+'A'); }
void MainWindow::loadRoom(int roomId){ mapUpdateTimer.stop(); RoomInfo &pMapInfo=mapdata.roomInfos[roomId]; if(pMapInfo.subFileIdData.subFileIdSlots.rawFrtPltId==RoomInfo::invalidId){ QMessageBox msgBox; msgBox.setText(tr("Failed to load block set data." "\nDefault block set data will be used.")); msgBox.setIcon(QMessageBox::Icon::Warning); msgBox.exec(); //return; plt.readFile(mapdata.rawFrtPlts(0)); tiles.readFile(mapdata.rawFrtTileSets(0)); blocks.readFile(mapdata.rawFrtBlockSets(0)); } else{ plt.readFile(mapdata.rawFrtPlts(pMapInfo.subFileIdData.subFileIdSlots.rawFrtPltId)); tiles.readFile(mapdata.rawFrtTileSets(pMapInfo.subFileIdData.subFileIdSlots.rawFrtTileSetId)); blocks.readFile(mapdata.rawFrtBlockSets(pMapInfo.subFileIdData.subFileIdSlots.rawFrtBlockSetId)); } pltTransit.doTransit(plt); blocksTransit.doAllTransit(blocks,tiles,pltTransit); map.readFile(mapdata.rawMaps(pMapInfo.subFileIdData.subFileIdSlots.rawMapId)); if(pMapInfo.subFileIdData.subFileIdSlots.rawBckScrId==RoomInfo::invalidId){ bckScr.unload(); } else{ bckPlt.readFile(mapdata.rawBckPlts(pMapInfo.subFileIdData.subFileIdSlots.rawBckPltId)); bckTiles.readFile(mapdata.rawBckTileSets(pMapInfo.subFileIdData.subFileIdSlots.rawBckTileSetId)); bckScr.readFile(mapdata.rawBckScrs(pMapInfo.subFileIdData.subFileIdSlots.rawBckScrId)); bckPltTransit.doTransit(bckPlt); } resetMap(); ui->blockStore->reset(); curRoomId=roomId; clearOperationStack(); emit itemTableModal.layoutChanged(); ui->itemTable->clearSelection(); ui->itemTable->resizeColumnsToContents(); ui->itemTable->resizeRowsToContents(); ui->menuMap->setEnabled(true); mapUpdateTimer.start(16); }
void Game_Manager::CreationMonde4(int difficulter) { //parfois chemin totalment bloquer resetMap(); int current = 3,precedent; for (int x = 5; x < MAXX; x++) { precedent = current; current = modifcourant(current); for (int y = 0; y < MAXY; y++) { if (y == current) { } else if ( y != precedent) { if (rand() % (difficulter+1)!=0) { if (rand() % 2) { Map[y][x].setObject(2 + rand() % 8); } else { Map[y][x].setLight(3); } } else { //vide } } else { if (rand() % 2 == 0) { Map[y][x].setMob(1 + rand() % 8); } else { //vide } } } } Lumiere(); }
FloorGenerator::FloorGenerator(const FloorGenerator &floor) { resetMap(); for(int i = 0; i < LIMIT; i++) { for(int j = 0; j < LIMIT; j++) { map[i][j] = floor.map[i][j]; } } room_num = floor.room_num; add_room = floor.add_room; }
Map::Map(int level,GameScene* parent) { /*map = NULL; mapUp = false; mapData = vector<int>(); createData(level); initMap(1); curLevel = 1;*/ speed = 5.5f; speedChange = 0; map = CCArray::create(); map->retain(); resetMap(level,parent); }
void Game_Manager::CreationMonde6() { //damier resetMap(); int choix; for (int x = 5; x < MAXX; x++) { choix = (rand() % 4) * 2; for (int y = 0; y < MAXY; y++) { if (x%2==0 &&y%2==1)//regle a { Map[y][x].setObject(1 + rand() % 9); } else if (y % 2==0 && x%2==0 && y == choix) { Map[y][x].setType(1 + rand() % 9, 1 + rand() % 8, 2); } else if (y % 2 == 0 && x % 2 == 0 && y != choix) { //vide } else if (x % 2 == 1 && y % 2 == 1) { if (rand()%2==0) { Map[y][x].setMob(1 + rand() % 8); } else { Map[y][x].setLight(2); } }//regle d else { } } } Lumiere(); }
bool MainWindow::judgeDoubleStar(int row1, int col1, int row2, int col2) { bool anySpawn=false; if (b[row1][col1]->number==5 && b[row2][col2]->number==5) { qDebug() << "Double Star"; for (int i=0; i<10; i++) { for (int j=0; j<10; j++) b[i][j]->number=0; } resetMap(); anySpawn=true; } return anySpawn; }
Map::Map(WrapperClass &WCR_) : WCR(WCR_) { //Setup the size of the map. CellSize = 32; MapWidth = 100; MapHeight = 100; ViewWidth = 640; ViewX = 0; ViewHeight = 480; ViewY = 0; SolidObj = sf::RectangleShape(sf::Vector2f(32, 32)); SolidObj.setFillColor(sf::Color::Blue); SolidObj.setSize(sf::Vector2f(32, 32)); //Fill map with null object ids. resetMap(); //setupBorders(); }
/*-------------------------------------------------------------------------------------------- -- FUNCTION: createTopScenery -- -- DATE: April 7th, 2016 -- -- DESIGNERS: Jaegar Sarauer -- -- REVISIONS: NONE -- -- PROGRAMMERS: Jaegar Sarauer -- -- INTERFACE: void Map::createTopScenery (int sceneryChance) -- int sceneryChance = The chance of spawning scenery. -- The chance of spawning is 1:sceneryChance + 1. -- -- RETURNS: void -- -- NOTES: The function will loop through the base layer of the map and check for -- walkable tiles. All walkable tiles will have a 1:sceneryChance + 1 in spawning -- a scenery object on the scenery layer of the map (unless there is a neighbooring -- scenery object). ------------------------------------------------------------------------------------------*/ void Map::createTopScenery (int sceneryChance) { resetMap (mapScenery, -1); for (int x = 0; x < mapWidth; x++) for (int y = 0; y < mapHeight; y++) { if (mapBase[x][y] > baseWallMax) if (rand () % sceneryChance == 0) if (x - 1 >= 0 && x + 1 < mapWidth && y - 1 >= 0 && y + 1 < mapHeight) for (int tX = x - 1; tX <= x + 1; tX++) { for (int tY = y - 1; tY <= y + 1; tY++) { if (mapScenery[tX][tY] != -1) break; if (tX == x + 1 && tY == y + 1) mapScenery[x][y] = rand () % (sceneryMax - sceneryDefault); } } } }
PiecesTable::PiecesTable(TQWidget* parent, const char* name ) : QtTableView(parent, name), _activeRow(-1), _activeCol(-1), _randomized(false) { _menu = new TQPopupMenu(this); _menu->insertItem(i18n("R&andomize Pieces"), this, TQT_SLOT(randomizeMap())); _menu->insertItem(i18n("&Reset Pieces"), this, TQT_SLOT(resetMap())); _menu->adjustSize(); // setup table view setFrameStyle(StyledPanel | Sunken); setBackgroundMode(NoBackground); setMouseTracking(true); setNumRows(4); setNumCols(4); // init arrays initMap(); initColors(); }
void Game_Manager::CreationMonde7(int difficulter) { resetMap(); int nbrlight = 0; int *ordre = NULL; int currentLight = 0, rndY = 0; for (int x = 5; x < MAXX; x++) { //pose des light currentLight = 0, rndY = 0; nbrlight =2+ rand() % difficulter; if (nbrlight > 5) { nbrlight =4; } if (nbrlight != 0) { while (currentLight < nbrlight) { rndY = rand() % MAXY; if (Map[rndY][x].getMob() == 0) { Map[rndY][x].setLight(2); currentLight++; } } } } }
int ColormapEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: newColorList((*reinterpret_cast< QList<QColor>(*)>(_a[1]))); break; case 1: rotate((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: bias((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: contrast((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: setColor(); break; case 5: okPressed(); break; case 6: applyPressed(); break; case 7: biasReset(); break; case 8: rotateReset(); break; case 9: contrastRest(); break; case 10: updateColormap(); break; case 11: resetMap((*reinterpret_cast< int(*)>(_a[1]))); break; } _id -= 12; } return _id; }
void Game_Manager::CreationMonde2(int difficulter) { resetMap(); int nbrmob = 0; int *ordre = NULL; int currentMob = 0, rndY = 0; for (int x = 5; x < MAXX; x++) { //pose des mobs currentMob = 0, rndY = 0; nbrmob = rand() % difficulter; if (nbrmob != 0) { while (currentMob < nbrmob) { rndY = rand() % MAXY; if (Map[rndY][x].getMob() == 0) { Map[rndY][x].setMob(1 + rand() % 8);////////////Differents sprites currentMob++; } } } } Lumiere(); }
void Map::mapMove(GameScene* parent,Role* role){ for(int i = 0;i < map->count();i++){ CCSprite* m = (CCSprite*)map->objectAtIndex(i); if(i == 0){ //第二大关卡开始,结束玩家飞行状态 if(role->getState() == Role::FLY){ if(m->getPositionX() > 0 && m->getTag() < 7 && m->getPositionX() <= Role::POSX){ role->nextLevel(); speed += 0.5; //每一关增加0.5速 度 parent->addSpeed(0.5); startCur = true; } } } if(m->getPositionX() > 854){ m->setVisible(false); } if(m->getPositionX()+m->getContentSize().width>= 0){ float x = m->getPositionX(); float y = m->getPositionY(); if(mapUp){ if(m->getTag() >= 7 ){ switch(m->getTag()){ case 7: if(y<-55){ y+=getSpeed() / 1.5f; } break; case 8: if(y < -75){ y+=getSpeed() / 1.5f; } break; case 9: if(y < -70){ y+=getSpeed() / 1.5f; } break; } }else{ if( y < 0){ y += getSpeed(); } } x -= getSpeed() / 1.5f; }else{ x -= getSpeed(); } //一关结束的地图向上移动 if(!mapUp && i >= map->count() - 3){ if(m->getPositionX() + 100 < 200){ mapUp = true; role->setProtect(true); } } m->setPosition(ccp(x,y)); if(m->getPositionX() < 854 && m->getPositionX() + m->getContentSize().width > 0){ m->setVisible(true); if(startCur && m->getTag() == 9 && m->getPositionX()< role->getPositionX() - role->getContentSize().width){ role->fly(true); startCur = false; } } }else{ } } CCSprite* last = (CCSprite*)map->lastObject(); if(last->getPositionX() + last->getContentSize().width <= 0 ){ for(int i = 0;i < map->count();i++){ parent->removeChild((CCSprite*)map->objectAtIndex(i),true); } map->removeAllObjects(); resetMap(curLevel + 1,parent); } if(startCur){ parent->setProgress(getPercent()); curDis += getSpeed(); } }
void Rgame::deeper(void) { resetMap(); hero.gainXp(2); }
void QtTDContext::loadMap(QUrl fetchUrl, QString relativeLoc) { resetMap(); //MapIO.readLevel(this, fetchUrl, relativeLoc); //mainApp.mapChanged(); }
void Game_Manager::CreationMonde3(int difficulter) { resetMap(); int obstacle = 0, nbrLight = 0; int *ordre = NULL; int currentLight = 0, currentObst = 0; int rndY = 0; for (int x = 5; x < MAXX; x++) { if (x % 2 == 0) { currentObst = NULL; currentLight = NULL; obstacle = 1 + rand() % (difficulter - 1); nbrLight = 1 + rand() % (difficulter - 1); //pose des obstacles if (obstacle != 0) { while (currentObst < obstacle) { rndY = rand() % MAXY; if (Map[rndY][x].getObject() == 0) { Map[rndY][x].setObject(rand() % 10);////////////Differents sprites currentObst++; } } } //pose des lumiere natuel if (nbrLight != 0) { while (currentLight < nbrLight) { rndY = rand() % MAXY; if (Map[rndY][x].getObject() == 0) { Map[rndY][x].setLight(3);////////////Differents sprites currentLight++; } } } } else { passagesecuriserMonde3(difficulter); } } }
bool QtTDContext::loadMap(QString maplocation) { resetMap(); bool retval = false;//= MapIO.readLevel( maplocation); //mainApp.mapChanged(); return retval; }
void Game_Manager::CreationMonde1(int difficulter) { resetMap(); int nbrmob = 0, obstacle = 0, nbrLight = 0; int *ordre = NULL; int currentLight = 0, currentObst = 0; int rndY = 0; for (int x = 5; x < MAXX; x++) { if (x % 2 != 0) { currentObst = NULL; currentLight = NULL; obstacle = rand() % difficulter; nbrLight = rand() % difficulter; //pose des obstacles if (obstacle != 0) { while (currentObst < obstacle) { rndY = rand() % MAXY; if (Map[rndY][x].getObject() == 0) { Map[rndY][x].setObject(1+rand() % 9);////////////Differents sprites currentObst++; } } } //pose des lumiere natuel if (nbrLight != 0) { while (currentLight < nbrLight) { rndY = rand() % MAXY; if (Map[rndY][x].getObject() == 0) { Map[rndY][x].setLight(3);////////////Differents sprites currentLight++; } } } } else { //pose des mobs int currentMob = 0, rndY = 0; int nbrmob = rand() % difficulter; if (nbrmob != 0) { while (currentMob < nbrmob) { rndY = rand() % MAXY; if (Map[rndY][x].getMob() == 0) { Map[rndY][x].setMob(1 + rand() % 8);////////////Differents sprites currentMob++; } } } } } Lumiere(); passagesecuriserMonde1(difficulter); }
void QtTDContext::loadMap(QTextStream b, QString maplocation) { resetMap(); //MapIO.readLevel(this, b, maplocation); //mainApp.mapChanged(); }
void FloorGenerator::generateMap(int floornum) { //start with a clean map. resetMap(); //Determine how many rooms the floor will have. switch(floornum) { case 1: case 2: case 3: case 4: { room_num = rand() % 2 + 5; break; } case 6: case 7: case 8: case 9: { room_num = rand() % 2 + 7; break; } case 11: case 12: case 13: case 14: { room_num = rand() % 2 + 9; break; } case 5: case 10: case 15: { room_num = 2; break; } } //Determine the starting point of the first room. Room starting; starting.setX(LIMIT / 2); starting.setY(LIMIT / 2); starting.setTreasure(false); starting.setStairs(false); starting.setType(true); starting.setArrival(true); //decrement the amount of rooms room_max = room_num; --room_num; unsigned char begin = ' '; //Determine the starting room //15 types of rooms int temp_num = rand() %15; switch(temp_num) { case 0: begin = roomoneU; break; case 1: begin = roomoneD; break; case 2: begin = roomoneL; break; case 3: begin = roomoneR; break; case 4: begin = roomtwoH; break; case 5: begin = roomtwoV; break; case 6: begin = roomtwoUR; break; case 7: begin = roomtwoDR; break; case 8: begin = roomtwoDL; break; case 9: begin = roomtwoUL; break; case 10: begin = roomthreeU; break; case 11: begin = roomthreeD; break; case 12: begin = roomthreeL; break; case 13: begin = roomthreeR; break; case 14: begin = roomfour; break; } starting.setIcon(begin); if(floornum == 5 || floornum == 10 || floornum == 15) { starting.setX(LIMIT/2); starting.setY(LIMIT/2); starting.setIcon(roomoneU); } map[starting.getX()][starting.getY()] = starting.getIcon(); start.push(starting); rooms.push_back(starting); addRC(floornum); if(!checkValidMap()) { while(!checkValidMap()) { resetMap(); emptyQueue(); emptyCor(); emptyRoom(); room_num = room_max - 1; map[starting.getX()][starting.getY()] = starting.getIcon(); start.push(starting); rooms.push_back(starting); addRC(floornum); } } //assign stairs to a room unsigned int stair_num = rand() % (rooms.size() - 1) + 1; for(unsigned int i = 0; i < rooms.size(); i++) { //arrival room should always be the first room in the vector if(rooms[i].getArrival()) continue; //set the stairs to a room if(i == stair_num) rooms[i].setStairs(true); //if the room isn't the arrival room, and the room doesn't have stairs, it can have a treasure if(!rooms[i].getArrival() && !rooms[i].getStairs()) { int temp = rand() % 2; if(temp == 1) rooms[i].setTreasure(true); } } }