diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 7efed204..a757e859 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -26,10 +26,9 @@ Crawler::Crawler() } bool Crawler::OnUserCreate(){ - TMXParser level1("assets/maps/Level1.tmx"); - MAP_DATA[LEVEL1]=level1.GetData(); - TMXParser level2("assets/maps/Level2.tmx"); - MAP_DATA[LEVEL2]=level2.GetData(); + InitializeLevel("assets/maps/Level1.tmx",LEVEL1); + InitializeLevel("assets/maps/Level2.tmx",LEVEL2); + InitializeLevel("assets/Campaigns/1_1.tmx",CAMPAIGN_1_1); //Initialize Camera. camera=Camera2D{WINDOW_SIZE}; @@ -796,6 +795,22 @@ void Crawler::SetupWorldShake(float duration){ camera.SetTarget(worldShake); } + +void Crawler::InitializeLevel(std::string mapFile,MapName map){ + TMXParser level(mapFile); + size_t slashMarker = mapFile.find_last_of('/'); + std::string baseDir=mapFile.substr(0,slashMarker+1); + MAP_DATA[map]=level.GetData(); + for(XMLTag&tag:MAP_DATA[map].TilesetData){ + if(tag.tag=="tileset"&&MAP_TILESETS.find(tag.data["source"])==MAP_TILESETS.end()){ + Renderable*r=new Renderable(); + MAP_TILESETS[tag.data["source"]]=r; + r->Load(baseDir+tag.data["source"]); + std::cout<<"Missing tileset:"<foregroundEffects,backgroundEffects; std::mapMAP_DATA; + std::mapMAP_TILESETS; vf2d worldShake={}; float worldShakeTime=0; float lastWorldShakeAdjust=0; @@ -36,6 +37,7 @@ public: bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; void InitializeAnimations(); + void InitializeLevel(std::string mapFile,MapName map); void HandleUserInput(float fElapsedTime); void UpdateCamera(float fElapsedTime); void UpdateEffects(float fElapsedTime); diff --git a/Crawler/Map.h b/Crawler/Map.h index 854317b1..2b9caa1e 100644 --- a/Crawler/Map.h +++ b/Crawler/Map.h @@ -2,4 +2,5 @@ enum MapName{ LEVEL1, LEVEL2, + CAMPAIGN_1_1, }; \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index f0010e0d..536ad049 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 121 +#define VERSION_BUILD 125 #define stringify(a) stringify_(a) #define stringify_(a) #a