void TileBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData) { if(loadMap(mapID, tileX, tileY, meshData, ENTIRE)) { loadMap(mapID, tileX+1, tileY, meshData, LEFT); loadMap(mapID, tileX-1, tileY, meshData, RIGHT); loadMap(mapID, tileX, tileY+1, meshData, TOP); loadMap(mapID, tileX, tileY-1, meshData, BOTTOM); } }
Ref<SceneGraph::MaterialNode> CoronaLoader::loadMaterial(const Ref<XML>& xml) { if (xml->name != "material") THROW_RUNTIME_ERROR(xml->loc.str()+": invalid material: "+xml->name); /* native material */ if (xml->parm("class") == "Native") { /* we convert into an OBJ material */ OBJMaterial objmaterial; for (auto child : xml->children) { if (child->name == "diffuse") { objmaterial.Kd = load<Vec3fa>(child); if (child->children.size() && child->children[0]->name == "map") objmaterial.map_Kd = loadMap(child->children[0]); } else if (child->name == "reflect") { objmaterial.Ks = load<Vec3fa>(child->child("color")); objmaterial.Ni = load<float >(child->child("ior")); objmaterial.Ns = load<float >(child->child("glossiness")); } else if (child->name == "translucency") { objmaterial.Kt = load<Vec3fa>(child->child("color")); } else if (child->name == "opacity") { objmaterial.d = load<Vec3fa>(child).x; if (child->children.size() && child->children[0]->name == "map") objmaterial.map_d = loadMap(child->children[0]); } } /* return material */ Material material; new (&material) OBJMaterial(objmaterial); return new SceneGraph::MaterialNode(material); } /* reference by name */ else if (xml->parm("class") == "Reference") { const std::string name = load<std::string>(xml); return materialMap[name]; } /* else return default material */ else { Material objmtl; new (&objmtl) OBJMaterial; return new SceneGraph::MaterialNode(objmtl); } }
std::shared_ptr<Texture> CoronaLoader::loadMap(const Ref<XML>& xml) { /* process map node */ if (xml->name == "map") { std::string mapClass = xml->parm("class"); /* load textures */ if (mapClass == "Texture") { const FileName src = load<FileName>(xml->child("image")); /* load images only once */ if (textureFileMap.find(src) != textureFileMap.end()) return textureFileMap[src]; try { return Texture::load(path+src); } catch (std::runtime_error e) { std::cerr << "failed to load " << path+src << ": " << e.what() << std::endl; } } else if (mapClass == "Reference") { const std::string name = load<std::string>(xml); return textureMap[name]; } } /* recurse into every unknown node to find some texture */ for (auto child : xml->children) { std::shared_ptr<Texture> texture = loadMap(child); if (texture) return texture; } return std::shared_ptr<Texture>(); }
scene::scene(string filename){ cout << "Reading scene frome " << filename << "..." << endl; cout << " " << endl; char* fname = (char*)filename.c_str(); fp_in.open(fname); if(fp_in.is_open()){ while(fp_in.good()){ string line; getline(fp_in, line); if(!line.empty()){ vector<string> tokens = utilityCore::tokenizeString(line); if(strcmp(tokens[0].c_str(), "MATERIAL")==0){ loadMaterial(tokens[1]); cout << " " << endl; }else if(strcmp(tokens[0].c_str(), "OBJECT")==0){ loadObject(tokens[1]); cout << " " << endl; }else if(strcmp(tokens[0].c_str(), "CAMERA")==0){ loadCamera(); cout << " " << endl; }else if(strcmp(tokens[0].c_str(), "MAP") == 0){ loadMap(tokens[1]); cout << " " << endl; } } } } }
///////////////////////////////////////////////////////////////////////////// // create a string that holds all the map information ///////////////////////////////////////////////////////////////////////////// CString CMapDatabase::getMapInfo(int iMap) { CString str; CString strTemp; CString strType; //load up the map in question loadMap(iMap); //map name strTemp.Format("Map: %s", m_Map.m_strMapName); str += strTemp; if(m_Map.m_iMode & MAP_SEAFARERS) { strType += "Seafarers, "; } if(m_Map.m_iMode & MAP_CITIESKNIGHTS) { strType += "Cities & Knights, "; } //if it's still empty, it's just a settlers game if(TRUE == strType.IsEmpty()) { strType = "Settlers, "; } //lose the comma strType = strType.Left(strType.GetLength() - 2); //type of game strTemp.Format("\nMap type: %s", strType); str += strTemp; //number of players if(m_Map.m_iMinPlayers == m_Map.m_iMaxPlayers) { strTemp.Format("\nPlayers: %d", m_Map.m_iMinPlayers); } else { strTemp.Format("\nPlayers: %d-%d", m_Map.m_iMinPlayers, m_Map.m_iMaxPlayers); } str += strTemp; //number of points strTemp.Format("\nPoints: %d", m_Map.m_iPoints); str += strTemp; //officialness strTemp.Format("\nOfficial: %s", m_Map.m_bOfficial ? "Yes" : "No"); str += strTemp; //creator strTemp.Format("\nMap creator: %s", m_Map.m_strMapCreator); str += strTemp; return str; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), Ui_MainWindow() { setupUi(this); connect(pushButton,SIGNAL(clicked()),this,SLOT(work())); connect(saveMapact,SIGNAL(triggered()),this,SLOT(saveMap())); connect(openMapact,SIGNAL(triggered()),this,SLOT(loadMap())); connect(openArract,SIGNAL(triggered()),this,SLOT(loadArr())); connect(saveArract,SIGNAL(triggered()),this,SLOT(saveArr())); nextBtn->setVisible(false); preBtn->setVisible(false); addBtn->setVisible(false); delBtn->setVisible(false); redoBtn->setVisible(false); findMBtn->setVisible(false); findSBtn->setVisible(false); listSBtn->setVisible(false); matchFBtn->setVisible(false); zinBtn->setVisible(false); zoutBtn->setVisible(false); for(int i=0;i<Hei;i++) for(int j=0;j<Wid;j++) { arrLayout->addWidget(&arrs[i][j],i,j,4,2); } }
Game::Game() { device = irr::createDevice(irr::video::EDT_OPENGL, {640,480}, 16, false, false, false, &event_receiver); assert(device); device->setWindowCaption(L"Eternal Sonata"); driver = device->getVideoDriver(); scene_manager = device->getSceneManager(); environment = device->getGUIEnvironment(); menu.setDevice(device); menu.setDevice(device); this->mapSelector = 0; this->game_set = false; character.setEventReceiver(&event_receiver); loadMeshes(); loadMap(); loadPlayer(); getMenu().showMainMenu(); getPlayer().debugCharacter(); }
// on "init" you need to initialize your instance bool HelloWorld::init() { if ( !Layer::init() ) { return false; } m_gamemap = NULL; m_player = NULL; m_routeAlgorithm = NULL; loadMap("gamemap.tmx"); loadGamePlayer(); initTileDatas(); //初始化寻路算法的地图数据 Size mapsize = m_gamemap->getMapSize(); m_routeAlgorithm = new RouteAlgorithm(mapsize.width, mapsize.height, m_tileDatas); m_routeAlgorithm->setAllowDiagonal(true);//允许对角线 m_routeAlgorithm->setAllowCrossConrner(false);//不允许穿越拐角 assert(m_routeAlgorithm != NULL); scheduleUpdate(); setTouchEnabled(true); return true; }
Room::Room(const Room& rhs) { this->filename = rhs.filename; //int filenameLength = strlen(rhs.filename); //this->filename = new char[filenameLength]; //this->filename = ""; //stringCopy(this->filename, rhs.filename); this->world = rhs.world; tilemap = 0; doorsGrid = 0; collisionGrid = 0; rowStart = 0; rowEnd = 0; colStart = 0; colEnd = 0; roomWidth = 0; roomHeight = 0; box = 0; distance=0.0f; doors.clear(); loadMap(); calculateBoundingBox(); locateDoors(); for(unsigned int i=0; i < doors.size(); i++) { Door* door = doors[i]; door->opened=true; } this->graphic = tilemap; }
Room::Room(char* filename, GameWorld* gameWorld) : Entity() { this->filename = filename; this->world = gameWorld; tilemap = 0; doorsGrid = 0; collisionGrid = 0; rowStart = 0; rowEnd = 0; colStart = 0; colEnd = 0; roomWidth = 0; roomHeight = 0; box = 0; distance=0.0f; doors.clear(); loadMap(); calculateBoundingBox(); locateDoors(); this->graphic = tilemap; }
Environment::Environment(const EnvironmentURL &url) : archivePath(fs::system_complete(getEnvironmentPath(url + ".sky"))), fileArchive(archivePath), workerRunning(false), loadError(false), loadProgress(0), url(url) { if (url == "NULL") { appLog("Creating null environment.", LogOrigin::Engine); workerThread = std::thread([&]() { loadNullMap(); }); } else { appLog("Creating environment " + inQuotes(url) + " with environment file " + archivePath.string(), LogOrigin::Engine); workerRunning = true; workerThread = std::thread([&]() { fileArchive.load(); if (const auto dir = fileArchive.getResult()) { if (const auto mapPath = dir->getTopFile("map.json")) { loadMap(mapPath.get()); } else { appLog(describeComponentMissing(Component::Map), LogOrigin::Error); loadError = true; } } else { appLog("Could not open environment archive at path " + archivePath.string(), LogOrigin::Error); loadError = true; } workerRunning = false; }); } }
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( ) ); }
/** * Run some tests using a given map and write results to log file. * First command line argument is name of map file. * Second command line argument is name of log file for output. */ int main(int argc, char** argv) { FILE* in; FILE* out; struct Map* map; char* mapfile = argv[1]; char* logfile = argv[2]; in = fopen(mapfile, "r"); out = fopen(logfile, "w"); fprintf(out, "load map from %s\n", mapfile); map = loadMap(in); fclose(in); fprintf(out, "%d rooms, %d exits/room\n", map->rooms, map->exitsPerRoom); test_nextRoom(out, map); test_neighbor(out, map); test_validPath(out, map); fprintf(out, "free map resources\n"); freeMap(map); fclose(out); return 0; }
void MagicTowerLoader::loadSavedGame(const QString& directoryName, const QString& saveName) { scene->reset(); loadMap(directoryName + "/" + saveName + ".mtsavedmap.ini"); QFile extraFile(directoryName + "/" + saveName + ".mtsavedextra.ini"); extraFile.open(QFile::ReadOnly); QTextStream extraFileStream(&extraFile); QString className; QMap<QString, QString> parameters; for(;;) { QString str = extraFileStream.readLine(); str = str.trimmed(); if(extraFileStream.atEnd() || (str.startsWith("[")&&str.endsWith("]"))) { if(className.size()>0) { if(className == "Character") { QString map = parameters["map"]; int x = parameters["x"].toInt(); int y = parameters["y"].toInt(); scene->setObjectAt(map,"character",x,y,getPreset<MagicTowerCharacter>("warrior")->clone()); MagicTowerCharacter* character = dynamic_cast<MagicTowerCharacter*>( scene->getObjectAt(map,"character",x,y)); if(character!=NULL) { QMap<QString, QString>::const_iterator i = parameters.begin(); while (i != parameters.end()) { if(i.key()=="x"||i.key()=="y"||i.key()=="map") { i++; continue; } character->setGameProperty(i.key(),i.value().toInt()); i++; } scene->setActiveCharacter(character); } } parameters.clear(); } str[0] = QChar(' '); str[str.size()-1] = QChar(' '); str = str.trimmed(); className = str; } else if(str.size()>0) { QStringList lineParts = str.split("="); if(lineParts.size()==2) { parameters[lineParts[0].trimmed()] = lineParts[1].trimmed(); } } if(extraFileStream.atEnd()) break; } extraFile.close(); }
//===========================================================================// Engine::Engine(const Config& config) : mConfig(config), mRenderPhysics(false), mElapsedTime(0.0), mTimePerFrame(1.0 / mConfig.framesPerSecond), mGraphics(mConfig.title, mConfig.windowPosition, mConfig.windowSize, mConfig.fullscreen, mConfig.vsync), mPhysicsRenderer(mGraphics.getWindow()), mPhysics(mConfig.gravity, mPhysicsRenderer), mScript(this) { Logger::info("Engine initialized"); mPhysicsRenderer.setRender(true); mInput.registerInput("render physics", std::vector<size_t>(1, Keyboard::NUM_1)); // Check for a default map if (!mConfig.defaultMap.empty()) { loadMap(mConfig.defaultMap); } }
int main(int argc, char **argv) { if (proto_server_init() < 0) { fprintf(stderr, "ERROR: failed to initialize proto_server subsystem\n"); exit(-1); } fprintf(stdout, "RPC Port: %d, Event Port: %d\n", proto_server_rpcport(), proto_server_eventport()); if (proto_server_start_rpc_loop() < 0) { fprintf(stderr, "ERROR: failed to start rpc loop\n"); exit(-1); } // load game map into maze var (maze is located in maze.c) loadMap(); shell(NULL); return 0; }
void MapLoader::load(const std::string &xmlFilename, ResourceHandler &handler) { XMLFile doc(xmlFilename); XMLElement *areaElement = doc.FirstChildElement("maps").FirstChildElement("area").ToElement(); while(areaElement) { u16 area = areaElement->IntAttribute("id"); XMLElement *mapElement = areaElement->FirstChildElement("map"); while(mapElement) { std::string name = mapElement->Attribute("name"); std::string tilesetName = mapElement->Attribute("tileset"); u16 x = mapElement->IntAttribute("x"); u16 y = mapElement->IntAttribute("y"); Tileset &tileset = handler.get<Tileset>(tilesetName); loadMap(name, area, x, y, tileset, handler); mapElement = mapElement->NextSiblingElement("map"); } areaElement = areaElement->NextSiblingElement("area"); } }
void CLevelPlay::reloadLevel() { loadMap( mMap.getLevel() ); // Create the special merge effect (Fadeout) gEffectController.setupEffect(new CDimDark(8)); }
int main(int argc, char *argv[]) { //setup the ROS node ros::init(argc, argv, "ar_map_navigate_bumpers"); ros::NodeHandle n1, n2, n3, n4; vel_pub = n2.advertise<geometry_msgs::Twist>("/cmd_vel", 1); //SET QUEUE SIZE = 1!!! (keep only last msg) pospub = n4.advertise<position_tracker::Position>("/position", 1); //SET QUEUE SIZE = 1!!! (keep only last msg) pos_sub = n1.subscribe("/position", 1, positionCallback); bump_sub = n3.subscribe("/sensorPacket", 1, bumperCallback); loadMap(); loadWaypoints(); list<position_tracker::Position *>::iterator it; for(it = waypoints.begin(); it != waypoints.end(); ++it) //reach every single waypoint generated by the planner { goal_pos_x = (*it)->x; goal_pos_y = (*it)->y; //move to the next waypoint while(sqrt(pow(goal_pos_x - cur_pos.x, 2) + pow(goal_pos_y - cur_pos.y, 2)) > Tdist) { ros::spinOnce(); }//end while(current goal is not reached) }//end while(1) }
void Game::nextMap() { mapIndex++; std::cout << mapIndex << std::endl; std::ostringstream nextMap; nextMap << "res/map/map" << mapIndex; loadMap(nextMap.str()); }
bool VenusScene::init() { ////////////////////////////// // 1. super init first if (!Layer::init()) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); loadMap("maps/PantallaMercurio/Venus.tmx", "Objetos", "Rocas2", "Rocas1", "bg1", "bg2", "FondoPrincipal", "Meta"); setEventHandlers(); createCharacter("maps/personajepequeno.png"); //createCharacterAnimation(); tileMap->addChild(playerOne->PlayerSprite, 2); crearParticulaFuego(Point(2200,120)); this->addChild(tileMap, -1, 1); setPointOfView(Point(playerOne->PlayerSprite->getPosition())); printf("x mapPosition %f", tileMap->getPosition().x); printf("x mapPosition %f", tileMap->getPosition().y); auto listener = EventListenerKeyboard::create(); cocos2d::Sprite* ptr = playerOne->PlayerSprite; while (metaCheck(Point(ptr->getPositionX(), ptr->getPositionY()-3)) == "Normal") { ptr->setPosition(Point(ptr->getPositionX() + 0.5, ptr->getPositionY() - 0.5)); ptr->setPosition(Point(ptr->getPositionX(), playerOne->PlayerSprite->getPositionY() - 1.5)); setPointOfView(Point(ptr->getPosition())); } listener->onKeyPressed = CC_CALLBACK_2(VenusScene::keyPressed, this); listener->onKeyReleased = CC_CALLBACK_2(VenusScene::keyReleased, this); this->schedule(schedule_selector(VenusScene::onKeyHold)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); //Carga de las estrellas de puntaje loadStars(); //Etiqueta en pantalla del marcador marcadores(); cargarPropulsores(); cargarNave(); //Método para verificar las distintas colisiones, en este caso, de estrellas para actualizar el puntaje schedule(schedule_selector(VenusScene::updateColision)); return true; }
void loadMaps(char *mapA, char *mapB, struct clonePos **retListA, struct clonePos **retListB, struct hash **retHashA, struct hash **retHashB) /* Load some maps. */ { char file[128], ext[64]; splitPath(mapA, NULL, file, ext); if (sameString(".dat", ext)) { readDat(mapA, retListA, retHashA, 0); readDat(mapA, retListB, retHashB, 1); } else { loadMap(mapA, retListA, retHashA); loadMap(mapB, retListB, retHashB); } }
GameMapSet::GameMapSet(const QString& fileName, int initialLevel, QObject* parent) : QObject(parent), m_fileName(fileName) { loadMap(); setLevel(initialLevel); }
Map::Map(){ walls = std::vector<SDL_Rect *>(); foods = std::vector<SDL_Rect *>(); foodsTotal = 0; loadMap( "map.txt" ); }
int main(int argc,char **argv) { if (argc < 2) return 1; MapHeader *m = loadMap(argv[1]); printf("%p\n",m); if (map_error) printf("ERROR: %s\n",map_error); }
void loadGame(void) { /* Chargement du background */ map.background = loadImage("graphics/background.png"); /* Chargement du Tileset */ map.tileSet = loadImage("graphics/tileset.png"); /* chargement de la map */ loadMap("map/map1.txt"); }
MapManager::MapManager(char* file, MapPieceChoices *pieceChoices, SceneManager *sceneManager, LightAndObjectsManager *lightMgr, SceneNodeManager *sceneNodeMgr ) : sceneManager(sceneManager) , pieceChoices(pieceChoices) , lightMgr(lightMgr) , sceneNodeMgr(sceneNodeMgr) { MAPROOT = ConstManager::getString("map_file_path"); chosenPieces = std::vector<int>(); loadMap(file); }
void Game::prevMap() { if(mapIndex > 0) { mapIndex--; std::cout << mapIndex << std::endl; std::ostringstream nextMap; nextMap << "res/map/map" << mapIndex; loadMap(nextMap.str()); } }
int main(int argc, char *argv[]) { if(argc < 2 || argc > 4) { printf("\n Usage: %s port [a|b] [name] \n",argv[0]); return 1; } sockfd = server_connect(argv[1]); if (sockfd < 0) { // something happened while trying to connect-- abort mission return -1; } parse_settings(argv[2], argv[3]); printf("Request name %s and team %d\n", name, team); //construct proper sendBuff //(name, team) snprintf(sendBuff, sizeof sendBuff, "%s %d", name, team); // send it send_to_server(); // read reply read_from_server(); //printf("Bytes written: %d. Bytes read: %d.\n%s\n", writtenbytes, readbytes, recvBuff); sscanf(recvBuff, "%s", recvName); printf("%s\n", recvBuff); char *ghs = "Game has already started"; if(strcmp(ghs, recvBuff) == 0){ close(sockfd); return 0; } initscr(); loading_screen(); display_teams(); start_color(); initscr(); loadMap(mapNameFromServer); teamInfoMap(); initBoard();/* creates play board */ refresh();/* Print it on to the real screen */ load_players(); //place_players(); control_test(); final_standings(); getch(); endwin(); close(sockfd); return 0; }
void CoronaLoader::loadMapDefinition(const Ref<XML>& xml) { if (xml->name != "mapDefinition") THROW_RUNTIME_ERROR(xml->loc.str()+": invalid map definition: "+xml->name); if (xml->children.size() != 1) THROW_RUNTIME_ERROR(xml->loc.str()+": invalid map definition"); const std::string name = xml->parm("name"); std::shared_ptr<Texture> texture = loadMap(xml->children[0]); if (texture) textureMap[name] = texture; }