diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp
index a9533a81..d2321dde 100644
--- a/Crawler/Crawler.cpp
+++ b/Crawler/Crawler.cpp
@@ -6,6 +6,7 @@
#include "Ability.h"
#include "Class.h"
#include "Version.h"
+#include "TMXParser.h"
#include "DEFINES.h"
//192x192
@@ -25,6 +26,8 @@ Crawler::Crawler()
}
bool Crawler::OnUserCreate(){
+ TMXParser("assets/maps/Level1.tmx");
+
//Initialize Camera.
camera=Camera2D{WINDOW_SIZE};
camera.SetMode(olc::utils::Camera2D::Mode::LazyFollow);
diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj
index 88829222..364e6471 100644
--- a/Crawler/Crawler.vcxproj
+++ b/Crawler/Crawler.vcxproj
@@ -181,6 +181,7 @@
+
diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters
index d916e1c0..067fd35e 100644
--- a/Crawler/Crawler.vcxproj.filters
+++ b/Crawler/Crawler.vcxproj.filters
@@ -78,6 +78,9 @@
Header Files
+
+ Header Files
+
diff --git a/Crawler/TMXParser.h b/Crawler/TMXParser.h
new file mode 100644
index 00000000..444d31ed
--- /dev/null
+++ b/Crawler/TMXParser.h
@@ -0,0 +1,171 @@
+#pragma once
+#include "olcPixelGameEngine.h"
+#include
+
+using namespace olc;
+
+struct XMLTag{
+ std::string tag;
+ std::map data;
+ const std::string FormatTagData(std::maptiles) {
+ std::string displayStr="";
+ for (std::map::iterator it=data.begin();it!=data.end();it++) {
+ displayStr+=" "+it->first+": "+it->second+"\n";
+ }
+ return displayStr;
+ }
+ friend std::ostream& operator << (std::ostream& os, XMLTag& rhs) {
+ os <<
+ rhs.tag <<"\n"<<
+ rhs.FormatTagData(rhs.data) <<"\n";
+
+ return os; }
+
+ int GetInteger(std::string dataTag) {
+ return std::stoi(data[dataTag]);
+ }
+ double GetDouble(std::string dataTag) {
+ return std::stod(data[dataTag]);
+ }
+ bool GetBool(std::string dataTag) {
+ if (data[dataTag]=="0") {
+ return false;
+ } else {
+ return true;
+ }
+
+ }
+};
+
+struct LayerTag{
+ XMLTag tag;
+ std::vector> tiles;
+ std::string str() {
+ std::string displayStr=tag.tag+"\n"+tag.FormatTagData(tag.data);
+ displayStr+=" DATA ("+std::to_string(tiles[0].size())+"x"+std::to_string(tiles.size())+")\n";
+ return displayStr;
+ }
+};
+
+struct Map{
+ XMLTag MapData;
+ XMLTag TilesetData;
+ std::vector LayerData;
+ std::string FormatLayerData(std::ostream& os, std::vectortiles) {
+ std::string displayStr;
+ for (int i=0;i>data;
+ if (data.empty()) continue;
+
+ if (accumulator.length()>0) {
+ accumulator+=" "+data;
+ //Check if it ends with '>'
+ if (data[data.length()-1]=='>') {
+ ParseTag(accumulator);
+ accumulator="";
+ }
+ } else
+ if (data[0]=='<') {
+ //Beginning of XML tag.
+ accumulator=data;
+ } else {
+ //Start reading in data for this layer.
+ std::vectorrowData;
+ while (data.find(",")!=std::string::npos) {
+ std::string datapiece = data.substr(0,data.find(","));
+ data = data.substr(data.find(",")+1,std::string::npos);
+ rowData.push_back(stoi(datapiece));
+ }
+ if (data.length()) {
+ rowData.push_back(stoi(data));
+ }
+ parsedMapInfo.LayerData[parsedMapInfo.LayerData.size()-1].tiles.push_back(rowData);
+ }
+ }
+
+ std::cout<<"Parsed Map Data:\n"<
-