#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "data.h" using namespace std; enum GAMESTATE{ CUTSCENE_1, GAMEWORLD }; #define WIDTH 256 #define HEIGHT 224 #define ALPHA_SCREEN1 128 #define ALPHA_SCREEN2 20 #define FADE_SPD 6 class SeasonsOfLoneliness : public olc::PixelGameEngine { public: SeasonsOfLoneliness() { sAppName = "Seasons of Loneliness"; } public: GAMESTATE GAME_STATE=CUTSCENE_1; int textInd=0; int cursorX=0; int transitionTime=0; bool fade=false; int transparency=0; int frameCount=0; float elapsedTime=0; const float TARGET_RATE = 1/60.0; std::string CUTSCENE_CONSOLE_TEXT = ""; bool OnUserCreate() override { SetPixelMode(olc::Pixel::ALPHA); //ConsoleCaptureStdOut(true); // Called once at the start, so create things here return true; } bool GetAnyKey() { switch (GAME_STATE) { case CUTSCENE_1:{ if (textInd>=STORY_TEXT1.length()) { fadeOut(); } }break; } } bool OnUserUpdate(float fElapsedTime) override { elapsedTime+=fElapsedTime; while (elapsedTime>TARGET_RATE) { elapsedTime-=TARGET_RATE; updateGame(); } drawGame(); // called once per frame return true; } void updateGame(){ frameCount++; if (fade&&transparency<255) { transparency=clamp(transparency+FADE_SPD,0,255); } else if (!fade&&transparency>0) { transparency=clamp(transparency-FADE_SPD,0,255); } switch (GAME_STATE) { case CUTSCENE_1:{ if (textIndWIDTH-32) { int tempIndex=textInd; while (CUTSCENE_CONSOLE_TEXT[--tempIndex]!=' ') { CUTSCENE_CONSOLE_TEXT.erase(tempIndex); cursorX--; } CUTSCENE_CONSOLE_TEXT.erase(tempIndex++); CUTSCENE_CONSOLE_TEXT+='\n'; cursorX=0; while (tempIndex