|
|
|
@ -23,7 +23,9 @@ public: |
|
|
|
|
public: |
|
|
|
|
GAMESTATE GAME_STATE=CUTSCENE_1; |
|
|
|
|
int textInd=0; |
|
|
|
|
int cursorX=0; |
|
|
|
|
int transitionTime=0; |
|
|
|
|
int frameCount=0; |
|
|
|
|
float elapsedTime=0; |
|
|
|
|
const float TARGET_RATE = 1/60.0; |
|
|
|
|
std::string CUTSCENE_CONSOLE_TEXT = ""; |
|
|
|
@ -44,25 +46,38 @@ public: |
|
|
|
|
updateGame(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (GetKey(olc::A).bPressed) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
drawGame(); |
|
|
|
|
// called once per frame
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void updateGame(){ |
|
|
|
|
frameCount++; |
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
case CUTSCENE_1:{ |
|
|
|
|
if (textInd<STORY_TEXT1.length()) { |
|
|
|
|
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[textInd++]; |
|
|
|
|
char c = STORY_TEXT1[textInd++]; |
|
|
|
|
CUTSCENE_CONSOLE_TEXT+=c; |
|
|
|
|
if (c!='\n') { |
|
|
|
|
cursorX++; |
|
|
|
|
} else { |
|
|
|
|
cursorX=0; |
|
|
|
|
} |
|
|
|
|
if (GetTextSize(CUTSCENE_CONSOLE_TEXT).x>WIDTH-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<textInd) { |
|
|
|
|
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[tempIndex++]; |
|
|
|
|
cursorX++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -73,10 +88,13 @@ public: |
|
|
|
|
void drawGame(){ |
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
case CUTSCENE_1:{ |
|
|
|
|
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,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); |
|
|
|
|
FillRectDecal({16+(cursorX)*8%(WIDTH-32),8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0)},{4,8},olc::GREEN); |
|
|
|
|
} else { |
|
|
|
|
FillRectDecal({16+(cursorX)*8%(WIDTH-32),8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0)},{4,8},olc::Pixel(0,255,0,(0.5*sin(frameCount*4/60.0)+0.5)*256)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|