|
|
@ -1,8 +1,17 @@ |
|
|
|
#define OLC_PGE_APPLICATION |
|
|
|
#define OLC_PGE_APPLICATION |
|
|
|
#include "pixelGameEngine.h" |
|
|
|
#include "pixelGameEngine.h" |
|
|
|
|
|
|
|
#include "data.h" |
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum GAMESTATE{ |
|
|
|
|
|
|
|
CUTSCENE_1, |
|
|
|
|
|
|
|
GAMEWORLD |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WIDTH 256 |
|
|
|
|
|
|
|
#define HEIGHT 224 |
|
|
|
|
|
|
|
|
|
|
|
class SeasonsOfLoneliness : public olc::PixelGameEngine |
|
|
|
class SeasonsOfLoneliness : public olc::PixelGameEngine |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
@ -12,26 +21,72 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
GAMESTATE GAME_STATE=CUTSCENE_1; |
|
|
|
|
|
|
|
int textInd=0; |
|
|
|
|
|
|
|
int transitionTime=0; |
|
|
|
|
|
|
|
float elapsedTime=0; |
|
|
|
|
|
|
|
const float TARGET_RATE = 1/60.0; |
|
|
|
|
|
|
|
std::string CUTSCENE_CONSOLE_TEXT = ""; |
|
|
|
|
|
|
|
|
|
|
|
bool OnUserCreate() override |
|
|
|
bool OnUserCreate() override |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetPixelMode(olc::Pixel::ALPHA); |
|
|
|
SetPixelMode(olc::Pixel::ALPHA); |
|
|
|
ConsoleCaptureStdOut(true); |
|
|
|
//ConsoleCaptureStdOut(true);
|
|
|
|
// Called once at the start, so create things here
|
|
|
|
// Called once at the start, so create things here
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
elapsedTime+=fElapsedTime; |
|
|
|
|
|
|
|
while (elapsedTime>TARGET_RATE) { |
|
|
|
|
|
|
|
elapsedTime-=TARGET_RATE; |
|
|
|
|
|
|
|
updateGame(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawGame(); |
|
|
|
// called once per frame
|
|
|
|
// called once per frame
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void updateGame(){ |
|
|
|
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
|
|
|
case CUTSCENE_1:{ |
|
|
|
|
|
|
|
if (textInd<STORY_TEXT1.length()) { |
|
|
|
|
|
|
|
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[textInd++]; |
|
|
|
|
|
|
|
if (GetTextSize(CUTSCENE_CONSOLE_TEXT).x>WIDTH-32) { |
|
|
|
|
|
|
|
int tempIndex=textInd; |
|
|
|
|
|
|
|
while (CUTSCENE_CONSOLE_TEXT[--tempIndex]!=' ') { |
|
|
|
|
|
|
|
CUTSCENE_CONSOLE_TEXT.erase(tempIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CUTSCENE_CONSOLE_TEXT.erase(tempIndex++); |
|
|
|
|
|
|
|
CUTSCENE_CONSOLE_TEXT+='\n'; |
|
|
|
|
|
|
|
while (tempIndex<textInd) { |
|
|
|
|
|
|
|
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[tempIndex++]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void drawGame(){ |
|
|
|
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
|
|
|
case CUTSCENE_1:{ |
|
|
|
|
|
|
|
if (textInd<STORY_TEXT1.length()) { |
|
|
|
|
|
|
|
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1}); |
|
|
|
|
|
|
|
FillRectDecal({16+((textInd+1)*8%(WIDTH-32),16+GetTextSize(CUTSCENE_CONSOLE_TEXT).y},{4,8},olc::GREEN); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
int main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
SeasonsOfLoneliness demo; |
|
|
|
SeasonsOfLoneliness demo; |
|
|
|
if (demo.Construct(256, 240, 4, 4)) |
|
|
|
if (demo.Construct(256, 224, 4, 4)) |
|
|
|
demo.Start(); |
|
|
|
demo.Start(); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|