diff --git a/SeasonsOfLoneliness.cpp b/SeasonsOfLoneliness.cpp index 3d9836e..9ae9ae0 100644 --- a/SeasonsOfLoneliness.cpp +++ b/SeasonsOfLoneliness.cpp @@ -22,6 +22,12 @@ enum TILES{ #define FADE_SPD 6 #define MOVE_SPD 0.01 +class Object{ + public: + float x,y; + olc::Decal*spr; +}; + class SeasonsOfLoneliness : public olc::PixelGameEngine { public: @@ -46,6 +52,10 @@ public: int MAP_HEIGHT=-1; olc::Decal*TILES; float PLAYER_COORDS[2] = {}; + std::vector OBJECTS; + + olc::Decal*DOME_DECAL; + std::map BASE_OBJECTS; void LoadMap(char*mapName) { std::ifstream f("assets/maps/map1"); @@ -57,6 +67,7 @@ public: } free(MAP); } + int y=0; if (f.is_open()) { while (f.good()) { @@ -68,7 +79,8 @@ public: if (MAP_HEIGHT==-1) { std::stringstream stream(data); stream>>MAP_HEIGHT; - } else { + } else + if (y>obj.x; + std::stringstream split2(data.substr(data.find(';')+1,data.find(';',data.find(";")+1)-(data.find(';')+1))); + split2>>obj.y; + std::string split3 = data.substr(data.find(';',data.find(";")+1)+1,data.length()-(data.find(';',data.find(";")+1)+1)); + obj.spr=BASE_OBJECTS[split3]; + printf("Loaded object %s: (%f,%f)\n",split3.c_str(),obj.x,obj.y); + OBJECTS.push_back(obj); } } } @@ -95,6 +117,8 @@ public: //ConsoleCaptureStdOut(true); // Called once at the start, so create things here TILES=new olc::Decal(new olc::Sprite("assets/tiles.png")); + DOME_DECAL=new olc::Decal(new olc::Sprite("assets/dome.png")); + BASE_OBJECTS["DOME"]=DOME_DECAL; LoadMap("map1"); return true; } @@ -217,6 +241,9 @@ public: } } } + for (auto&obj:OBJECTS) { + DrawDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.spr); + } }break; } FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency)); diff --git a/Seasons_of_Loneliness b/Seasons_of_Loneliness index 85e0dcb..f0aef83 100755 Binary files a/Seasons_of_Loneliness and b/Seasons_of_Loneliness differ diff --git a/assets/maps/map1 b/assets/maps/map1 index 7b700f8..bcf2b18 100644 --- a/assets/maps/map1 +++ b/assets/maps/map1 @@ -38,4 +38,5 @@ 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \ No newline at end of file +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +38;18;DOME \ No newline at end of file