diff --git a/SeasonsOfLoneliness.cpp b/SeasonsOfLoneliness.cpp index 35014cc..a4993ab 100644 --- a/SeasonsOfLoneliness.cpp +++ b/SeasonsOfLoneliness.cpp @@ -7,6 +7,10 @@ using namespace olc; +#define STARTING_MAP "assets/maps/map1" +#define STARTING_STATE CUTSCENE_1 +#define MOVE_SPD 0.1 + enum GAMESTATE{ CUTSCENE_1, CUTSCENE_2, @@ -24,7 +28,9 @@ namespace cutscene{ CUTSCENE_4, TRANSITION_CUTSCENE, //Exit the dome. TRANSITION_CUTSCENE_2, //Enter the dome. - NODE_COLLECT_CUTSCENE + NODE_COLLECT_CUTSCENE, + PAN_OVER_TO_CROPS, + RAINING_IN_DOME, }; } @@ -47,7 +53,6 @@ namespace battle{ #define ALPHA_SCREEN1 128 #define ALPHA_SCREEN2 20 #define FADE_SPD 6 -#define MOVE_SPD 0.1 #define MESSAGE_SCROLL_WAIT_SPD 2 //Number of frames to wait. #define BATTLE_CAMERA_SCROLL_SPD 0.05 //How fast to scroll over to the battle. @@ -87,6 +92,9 @@ class ObjectLoadInfo{ Decal*spr; bool hasanim=false; Animation*anim; + vi2d spos; + vi2d size; + bool hascut=false; ObjectLoadInfo(Decal*spr) { this->spr=spr; } @@ -96,6 +104,12 @@ class ObjectLoadInfo{ this->hasanim=true; updateAnimationsList.push_back(anim); } + ObjectLoadInfo(Decal*spr,vi2d spos,vi2d size) { + this->spr=spr; + this->hascut=true; + this->spos=spos; + this->size=size; + } }; class Object{ @@ -105,6 +119,9 @@ class Object{ std::string name; bool hasAnim=false; Animation*anim; + vi2d spos; + vi2d size; + bool hascut=false; }; class ParticleEffect{ @@ -229,10 +246,9 @@ public: sAppName = "Seasons of Loneliness"; } -#define STARTING_MAP "assets/maps/map2" public: - GAMESTATE GAME_STATE=GAMEWORLD; + GAMESTATE GAME_STATE=STARTING_STATE; int textInd=0; int cursorX=0; int transitionTime=0; @@ -248,7 +264,7 @@ public: int MAP_HEIGHT=-1; Decal*TILES; float PLAYER_COORDS[2] = {14,4}; - std::vector OBJECTS; + std::vector OBJECTS; bool CUTSCENE_ACTIVE=false; cutscene::CUTSCENE CURRENT_CUTSCENE=cutscene::NONE; int CUTSCENE_TIMER=0; @@ -485,6 +501,7 @@ public: BASE_OBJECTS["METEORSHOWER_NODE"]=new ObjectLoadInfo(POWER_METEOR_SHOWER_DECAL,&POWER_METEOR_SHOWER_ANIMATION); BASE_OBJECTS["METEORSTORM_NODE"]=new ObjectLoadInfo(POWER_METEOR_STORM_DECAL,&POWER_METEOR_STORM_ANIMATION); BASE_OBJECTS["SNOWSTORM_NODE"]=new ObjectLoadInfo(POWER_SNOWSTORM_DECAL,&POWER_SNOWSTORM_ANIMATION); + BASE_OBJECTS["PLAYER_BACK"]=new ObjectLoadInfo(PLAYER_DECAL); for (int i=0;iplayerOwnCount+=amountGained; - std::cout<<"Increased HAILSTORM power inventory count by "<playerOwnCount+=amountGained; - std::cout<<"Increased HURRICANE power inventory count by "<playerOwnCount+=amountGained; - std::cout<<"Increased METEORSHOWER power inventory count by "<playerOwnCount+=amountGained; - std::cout<<"Increased METEORSTORM power inventory count by "<playerOwnCount+=amountGained; - std::cout<<"Increased SNOWSTORM power inventory count by "<name.compare("HAILSTORM_NODE")==0&&collidesWithPlayer(obj)) { + int amountGained=rand()%4+2; + HAILSTORM->playerOwnCount+=amountGained; + std::cout<<"Increased HAILSTORM power inventory count by "<name.compare("HURRICANE_NODE")==0&&collidesWithPlayer(obj)) { + int amountGained=rand()%4+2; + HURRICANE->playerOwnCount+=amountGained; + std::cout<<"Increased HURRICANE power inventory count by "<name.compare("METEORSHOWER_NODE")==0&&collidesWithPlayer(obj)) { + int amountGained=rand()%4+2; + METEOR_RAIN->playerOwnCount+=amountGained; + std::cout<<"Increased METEORSHOWER power inventory count by "<name.compare("METEORSTORM_NODE")==0&&collidesWithPlayer(obj)) { + int amountGained=rand()%4+2; + METEOR_STORM->playerOwnCount+=amountGained; + std::cout<<"Increased METEORSTORM power inventory count by "<name.compare("SNOWSTORM_NODE")==0&&collidesWithPlayer(obj)) { + int amountGained=rand()%4+2; + SNOWSTORM->playerOwnCount+=amountGained; + std::cout<<"Increased SNOWSTORM power inventory count by "<name.compare("EXIT")==0&&collidesWithPlayer(obj)) { + fadeOut(); + PlayCutscene(cutscene::TRANSITION_CUTSCENE); + } else + if (obj->name.compare("DOME")==0&&collidesWithPlayer(obj)) { + fadeOut(); + PlayCutscene(cutscene::TRANSITION_CUTSCENE_2); + } } } @@ -1039,15 +1063,8 @@ public: CUTSCENE_FLAGS[1]=true; DisplayMessageBox(1); } else - if (!CUTSCENE_FLAGS[2]) { - CUTSCENE_FLAGS[2]=true; - DisplayMessageBox(2); - foodMeterVisible=true; - } else - if (!CUTSCENE_FLAGS[3]) { - CUTSCENE_FLAGS[3]=true; - DisplayMessageBox(3); - oxygenMeterVisible=true; + { + PlayCutscene(cutscene::PAN_OVER_TO_CROPS); } } }break; @@ -1282,23 +1299,26 @@ public: } } for (auto&obj:OBJECTS) { - if (obj.spr!=NULL) { - if (obj.name.compare("PLANT")==0) { - DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},obj.spr,{getPlantStatus(obj.x,obj.y)*32,0},{32,32}); + if (obj->spr!=NULL) { + if (obj->name.compare("PLANT")==0) { + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},obj->spr,{getPlantStatus(obj->x,obj->y)*32,0},{32,32}); } else { - if (obj.name.find("NODE")!=std::string::npos) { - DrawDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2-32+18,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2-32+26},WEATHERNODE_EFFECT_DECAL); - DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2-16*(float)sin(frameCount*2/60.0)+16,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.anim->spr,{obj.anim->getCurrentFrame().x,obj.anim->getCurrentFrame().y},{obj.anim->width,obj.anim->height},{(float)sin(frameCount*2/60.0),1},Pixel((float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0+M_PI)+65*125,255)); + if (obj->name.find("NODE")!=std::string::npos) { + DrawDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2-32+18,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2-32+26},WEATHERNODE_EFFECT_DECAL); + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2-16*(float)sin(frameCount*2/60.0)+16,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->anim->spr,{obj->anim->getCurrentFrame().x,obj->anim->getCurrentFrame().y},{obj->anim->width,obj->anim->height},{(float)sin(frameCount*2/60.0),1},Pixel((float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0+M_PI)+65*125,255)); } else - if (obj.hasAnim) { - DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2+(obj.anim->flipped?32:0),(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.anim->spr,{obj.anim->getCurrentFrame().x,obj.anim->getCurrentFrame().y},{obj.anim->width,obj.anim->height},{obj.anim->flipped?-1:1,1}); + if (obj->hasAnim) { + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2+(obj->anim->flipped?32:0),(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->anim->spr,{obj->anim->getCurrentFrame().x,obj->anim->getCurrentFrame().y},{obj->anim->width,obj->anim->height},{obj->anim->flipped?-1:1,1}); + } else + if (obj->hascut) { + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr,obj->spos,{obj->anim->width,obj->anim->height},{obj->anim->flipped?-1:1,1}); } else { - DrawDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.spr); + DrawDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr); } } } else - if (obj.name.compare("EXIT")==0) { - GradientFillRectDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},Pixel(0,0,0,0),WHITE,WHITE,Pixel(0,0,0,0)); + if (obj->name.compare("EXIT")==0) { + GradientFillRectDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},Pixel(0,0,0,0),WHITE,WHITE,Pixel(0,0,0,0)); } } for (auto&enc:ENCOUNTERS) { @@ -1388,6 +1408,9 @@ public: free(MAP); MAP=NULL; } + for (int i=0;i>obj.x; + split1>>obj->x; std::stringstream split2(data.substr(data.find(';')+1,data.find(';',data.find(";")+1)-(data.find(';')+1))); - split2>>obj.y; + 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]->spr; + obj->spr=BASE_OBJECTS[split3]->spr; if (BASE_OBJECTS[split3]->hasanim) { - obj.hasAnim=true; - obj.anim=BASE_OBJECTS[split3]->anim; + obj->hasAnim=true; + obj->anim=BASE_OBJECTS[split3]->anim; } } else { - obj.spr=NULL; + obj->spr=NULL; } - obj.name=split3; - printf("Loaded object %s: (%f,%f)\n",split3.c_str(),obj.x,obj.y); + obj->name=split3; + printf("Loaded object %s: (%f,%f)\n",split3.c_str(),obj->x,obj->y); OBJECTS.push_back(obj); } } @@ -1447,17 +1470,17 @@ public: current_playerAnim.frame=0; } - bool collidesWithPlayer(Object obj) { - if (obj.hasAnim) { - return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+obj.anim->width/32.0&& - PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+obj.anim->height/32.0; + bool collidesWithPlayer(Object*obj) { + if (obj->hasAnim) { + return PLAYER_COORDS[0]>=obj->x&&PLAYER_COORDS[0]<=obj->x+obj->anim->width/32.0&& + PLAYER_COORDS[1]>=obj->y&&PLAYER_COORDS[1]<=obj->y+obj->anim->height/32.0; } else { - if (obj.spr==NULL) { - return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+1&& - PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+1; + if (obj->spr==NULL) { + return PLAYER_COORDS[0]>=obj->x&&PLAYER_COORDS[0]<=obj->x+1&& + PLAYER_COORDS[1]>=obj->y&&PLAYER_COORDS[1]<=obj->y+1; } else { - return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+obj.spr->sprite->width/32.0&& - PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+obj.spr->sprite->height/32.0; + return PLAYER_COORDS[0]>=obj->x&&PLAYER_COORDS[0]<=obj->x+obj->spr->sprite->width/32.0&& + PLAYER_COORDS[1]>=obj->y&&PLAYER_COORDS[1]<=obj->y+obj->spr->sprite->height/32.0; } } } @@ -1742,10 +1765,15 @@ public: return random(val2-val1)+val1; } + vi2d GetMapFileCoords(int ln,int col) { + return {col-1,ln-3}; + } + //Basically, click on a spot in the text editor and this function translates it into the proper teleport coords so you don't have to. void TeleportToMapFileCoords(int ln,int col) { - PLAYER_COORDS[0]=col-1+0.5; - PLAYER_COORDS[1]=ln-3+0.5; + vi2d teleLoc = GetMapFileCoords(ln,col); + PLAYER_COORDS[0]=teleLoc.x+0.5; + PLAYER_COORDS[1]=teleLoc.y+0.5; } }; diff --git a/Seasons_of_Loneliness b/Seasons_of_Loneliness index 46bb848..1660dac 100755 Binary files a/Seasons_of_Loneliness and b/Seasons_of_Loneliness differ diff --git a/data.h b/data.h index 349fb39..1b73839 100644 --- a/data.h +++ b/data.h @@ -21,7 +21,7 @@ std::string STORY_DIALOG[]={R"( RAIN CYCLE COMMENCING)", //0 R"( $PLAYER -Phew, thank goodness these came up just in time!)", //1 +Oh thank goodness, and just in time too!)", //1 R"( CompU-16770 RAIN CYCLE ENDING. NEXT RAIN CYCLE DUE IN 17 TERRESTIAL CYCLES.)", //2