diff --git a/SeasonsOfLoneliness.cpp b/SeasonsOfLoneliness.cpp index 3aa2e31..86f6e09 100644 --- a/SeasonsOfLoneliness.cpp +++ b/SeasonsOfLoneliness.cpp @@ -14,14 +14,8 @@ enum GAMESTATE{ WAITING_FOR_CUTSCENE_3, }; -enum TILES{ - DIRT, - GRASS, - WATER, - PLANTS -}; - enum CUTSCENE{ + NONE, PAN_DOME, PAUSE_TO_CUTSCENE_3, CUTSCENE_4, @@ -39,6 +33,7 @@ class Object{ public: float x,y; olc::Decal*spr; + std::string name; }; class SeasonsOfLoneliness : public olc::PixelGameEngine @@ -50,7 +45,7 @@ public: } public: - GAMESTATE GAME_STATE=CUTSCENE_1; + GAMESTATE GAME_STATE=GAMEWORLD; int textInd=0; int cursorX=0; int transitionTime=0; @@ -67,7 +62,7 @@ public: float PLAYER_COORDS[2] = {}; std::vector OBJECTS; bool CUTSCENE_ACTIVE=false; - CUTSCENE CURRENT_CUTSCENE=PAN_DOME; + CUTSCENE CURRENT_CUTSCENE=NONE; int CUTSCENE_TIMER=0; bool CUTSCENE_FLAGS[8]; bool messageBoxVisible=false; @@ -81,79 +76,27 @@ public: int foodCount=3; bool oxygenMeterVisible=false; int oxygenQualityLevel=34; + int plantState=0b10010110101000101010100110101010; olc::SplashScreen splash; - olc::Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL; + olc::Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL,*PLANT_DECAL; std::map BASE_OBJECTS; - void LoadMap(char*mapName) { - std::ifstream f(mapName); - std::string data; - MAP_WIDTH=MAP_HEIGHT=-1; - if (MAP!=NULL) { - for (int y=0;y>data; - if (MAP_WIDTH==-1) { - std::stringstream stream(data); - stream>>MAP_WIDTH; - } else - if (MAP_HEIGHT==-1) { - std::stringstream stream(data); - stream>>MAP_HEIGHT; - } 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); - } - } - } - printf("Loaded %dx%d map:\n",MAP_WIDTH,MAP_HEIGHT); - for (int y=0;y=0&&(int)(xOffset+x)=0&&(int)(yOffset+y)>getPlantId(obj)*2&0b11; + } + void DrawDialogBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) { FillRectDecal({(float)pos.x,(float)pos.y},size,p2); FillRectDecal({(float)pos.x+1,(float)pos.y+1},{(float)size.x-2,(float)size.y-2},p); @@ -486,6 +455,11 @@ public: void fadeIn() { fade=false; } + + void EndCutscene() { + CURRENT_CUTSCENE=NONE; + } + void DisplayMessageBox(int dialogNumber) { messageBoxVisible=true; messageBoxCursor=0; @@ -496,6 +470,67 @@ public: messageBoxText=""; messageBoxRefText=split3; } + + void LoadMap(char*mapName) { + std::ifstream f(mapName); + std::string data; + MAP_WIDTH=MAP_HEIGHT=-1; + if (MAP!=NULL) { + for (int y=0;y>data; + if (MAP_WIDTH==-1) { + std::stringstream stream(data); + stream>>MAP_WIDTH; + } else + if (MAP_HEIGHT==-1) { + std::stringstream stream(data); + stream>>MAP_HEIGHT; + } 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)); + if (split3.compare("NULL")!=0) { + obj.spr=BASE_OBJECTS[split3]; + } else { + obj.spr=NULL; + } + obj.name=split3; + printf("Loaded object %s: (%f,%f)\n",split3.c_str(),obj.x,obj.y); + OBJECTS.push_back(obj); + } + } + } + printf("Loaded %dx%d map:\n",MAP_WIDTH,MAP_HEIGHT); + for (int y=0;y