diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 2c2248ae..ac9894ea 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -29,7 +29,7 @@ Crawler::Crawler() bool Crawler::OnUserCreate(){ InitializeLevel("assets/maps/Level1.tmx",LEVEL1); InitializeLevel("assets/maps/Level2.tmx",LEVEL2); - InitializeLevel("assets/maps/1_1_test.tmx",CAMPAIGN_1_1); + InitializeLevel("assets/Campaigns/1_1_test.tmx",CAMPAIGN_1_1); //Initialize Camera. camera=Camera2D{WINDOW_SIZE}; @@ -133,7 +133,7 @@ bool Crawler::OnUserCreate(){ ,{MonsterName::SLIME_BLUE,{(rand()%20/2.f-5)*24,(rand()%20/2.f-5)*24}} }})); - LoadLevel(LEVEL1); + LoadLevel(CAMPAIGN_1_1); return true; } @@ -817,10 +817,14 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ std::string baseDir=mapFile.substr(0,slashMarker+1); MAP_DATA[map]=level.GetData(); for(XMLTag&tag:MAP_DATA[map].TilesetData){ - TSXParser tileset(baseDir+tag.data["source"]); - Renderable*r=new Renderable(); - MAP_TILESETS[baseDir+tag.data["source"]]=r; - r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); + size_t slashMarkerSourceDir = tag.data["source"].find_last_of('/'); + std::string baseSourceDir=tag.data["source"].substr(slashMarkerSourceDir+1); + if(MAP_TILESETS.find("assets/maps/"+baseSourceDir)==MAP_TILESETS.end()){ + TSXParser tileset(baseDir+tag.data["source"]); + Renderable*r=new Renderable(); + MAP_TILESETS["assets/maps/"+baseSourceDir]=r; + r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); + } } } @@ -836,14 +840,20 @@ vi2d Crawler::GetWorldSize(){ TilesheetData Crawler::GetTileSheet(MapName map,int tileID){ std::vector&tileData=MAP_DATA[map].TilesetData; if(tileData.size()==1){ - return {*MAP_TILESETS["assets/maps/"+tileData[0].data["source"]],1}; + size_t slashMarkerSourceDir = tileData[0].data["source"].find_last_of('/'); + std::string baseSourceDir=tileData[0].data["source"].substr(slashMarkerSourceDir+1); + return {*MAP_TILESETS["assets/maps/"+baseSourceDir],1}; } else { for (int i=1;i - + 31,32,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,