|
|
@ -144,10 +144,16 @@ public: |
|
|
|
DOME_DECAL=new olc::Decal(new olc::Sprite("assets/dome.png")); |
|
|
|
DOME_DECAL=new olc::Decal(new olc::Sprite("assets/dome.png")); |
|
|
|
BASE_OBJECTS["DOME"]=DOME_DECAL; |
|
|
|
BASE_OBJECTS["DOME"]=DOME_DECAL; |
|
|
|
LoadMap("assets/maps/map1"); |
|
|
|
LoadMap("assets/maps/map1"); |
|
|
|
|
|
|
|
DisplayMessageBox(7); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool GetAnyKey() override {
|
|
|
|
void GetAnyKeyPress() override {
|
|
|
|
|
|
|
|
if (messageBoxVisible) { |
|
|
|
|
|
|
|
while (messageBoxCursor<messageBoxRefText.length()) { |
|
|
|
|
|
|
|
advanceMessageBox(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
switch (GAME_STATE) { |
|
|
|
switch (GAME_STATE) { |
|
|
|
case CUTSCENE_1:{ |
|
|
|
case CUTSCENE_1:{ |
|
|
|
if (textInd>=STORY_TEXT1.length()) { |
|
|
|
if (textInd>=STORY_TEXT1.length()) { |
|
|
@ -155,7 +161,6 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
@ -234,37 +239,10 @@ public: |
|
|
|
if (messageBoxVisible) { |
|
|
|
if (messageBoxVisible) { |
|
|
|
if (frameCount%MESSAGE_SCROLL_WAIT_SPD==0) { |
|
|
|
if (frameCount%MESSAGE_SCROLL_WAIT_SPD==0) { |
|
|
|
if (messageBoxCursor<messageBoxRefText.length()) { |
|
|
|
if (messageBoxCursor<messageBoxRefText.length()) { |
|
|
|
char c = messageBoxRefText[messageBoxCursor++]; |
|
|
|
advanceMessageBox(); |
|
|
|
printf("%c",c); |
|
|
|
|
|
|
|
if (c=='\n') { |
|
|
|
|
|
|
|
if (!firstNewline) { |
|
|
|
|
|
|
|
firstNewline=true; |
|
|
|
|
|
|
|
goto next; |
|
|
|
|
|
|
|
} else if (!secondNewline) { |
|
|
|
|
|
|
|
secondNewline=true; |
|
|
|
|
|
|
|
goto next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (firstNewline&&!secondNewline) { |
|
|
|
|
|
|
|
messageBoxSpeaker+=c; |
|
|
|
|
|
|
|
goto next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
messageBoxText+=c; |
|
|
|
|
|
|
|
if (GetTextSizeProp(messageBoxText).x>WIDTH-16) { |
|
|
|
|
|
|
|
int tempIndex=messageBoxCursor; |
|
|
|
|
|
|
|
while (messageBoxText[--tempIndex]!=' ') { |
|
|
|
|
|
|
|
messageBoxText.erase(tempIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
messageBoxText.erase(tempIndex++); |
|
|
|
|
|
|
|
messageBoxText+='\n'; |
|
|
|
|
|
|
|
while (tempIndex<messageBoxCursor) { |
|
|
|
|
|
|
|
messageBoxText+=messageBoxRefText[tempIndex++]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
next: |
|
|
|
|
|
|
|
if (GetKey(olc::F1).bPressed) { |
|
|
|
if (GetKey(olc::F1).bPressed) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -354,6 +332,36 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void advanceMessageBox() { |
|
|
|
|
|
|
|
char c = messageBoxRefText[messageBoxCursor++]; |
|
|
|
|
|
|
|
printf("%c",c); |
|
|
|
|
|
|
|
if (c=='\n') { |
|
|
|
|
|
|
|
if (!firstNewline) { |
|
|
|
|
|
|
|
firstNewline=true; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else if (!secondNewline) { |
|
|
|
|
|
|
|
secondNewline=true; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (firstNewline&&!secondNewline) { |
|
|
|
|
|
|
|
messageBoxSpeaker+=c; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
messageBoxText+=c; |
|
|
|
|
|
|
|
if (GetTextSizeProp(messageBoxText).x>WIDTH-16) { |
|
|
|
|
|
|
|
int tempIndex=messageBoxCursor; |
|
|
|
|
|
|
|
while (messageBoxText[--tempIndex]!=' ') { |
|
|
|
|
|
|
|
messageBoxText.erase(tempIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
messageBoxText.erase(tempIndex++); |
|
|
|
|
|
|
|
messageBoxText+='\n'; |
|
|
|
|
|
|
|
while (tempIndex<messageBoxCursor) { |
|
|
|
|
|
|
|
messageBoxText+=messageBoxRefText[tempIndex++]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void drawGame(){ |
|
|
|
void drawGame(){ |
|
|
|
switch (GAME_STATE) { |
|
|
|
switch (GAME_STATE) { |
|
|
|
case CUTSCENE_1:{ |
|
|
|
case CUTSCENE_1:{ |
|
|
@ -385,11 +393,12 @@ public: |
|
|
|
GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1}); |
|
|
|
GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1}); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (messageBoxVisible) { |
|
|
|
|
|
|
|
DrawDialogBox({4,HEIGHT-60},{WIDTH/3,16},olc::Pixel(18, 0, 33,180)); |
|
|
|
DrawDialogBox({4,HEIGHT-60},{WIDTH/3,16},olc::Pixel(18, 0, 33,180)); |
|
|
|
DrawDialogBox({0,HEIGHT-48},{WIDTH,48},olc::Pixel(18, 0, 33,180)); |
|
|
|
DrawDialogBox({0,HEIGHT-48},{WIDTH,48},olc::Pixel(18, 0, 33,180)); |
|
|
|
DrawStringPropDecal({8,HEIGHT-40},messageBoxText); |
|
|
|
DrawStringPropDecal({8,HEIGHT-40},messageBoxText); |
|
|
|
DrawStringPropDecal({8,HEIGHT-57},messageBoxSpeaker); |
|
|
|
DrawStringPropDecal({8,HEIGHT-57},messageBoxSpeaker); |
|
|
|
|
|
|
|
if (messageBoxCursor==messageBoxRefText.length()) { |
|
|
|
|
|
|
|
DrawStringPropDecal({WIDTH-16-sin(frameCount*8/60.0)*3,HEIGHT-8+cos(frameCount*6/60.0)*0.6},"v",olc::Pixel(173, 74, 255,(0.5*sin(frameCount*8/60.0)+0.5)*128+128),{sin(frameCount*8/60.0),0.5}); |
|
|
|
} |
|
|
|
} |
|
|
|
FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency)); |
|
|
|
FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency)); |
|
|
|
} |
|
|
|
} |
|
|
@ -427,9 +436,12 @@ public: |
|
|
|
void DisplayMessageBox(int dialogNumber) { |
|
|
|
void DisplayMessageBox(int dialogNumber) { |
|
|
|
messageBoxVisible=true; |
|
|
|
messageBoxVisible=true; |
|
|
|
messageBoxCursor=0; |
|
|
|
messageBoxCursor=0; |
|
|
|
messageBoxSpeaker=""; |
|
|
|
std::string split1=STORY_DIALOG[dialogNumber].substr(0,STORY_DIALOG[dialogNumber].find('\n')); //Unused for now.
|
|
|
|
|
|
|
|
std::string split2=STORY_DIALOG[dialogNumber].substr(STORY_DIALOG[dialogNumber].find('\n')+1,STORY_DIALOG[dialogNumber].find('\n',STORY_DIALOG[dialogNumber].find('\n')+1)-(STORY_DIALOG[dialogNumber].find('\n')+1)); |
|
|
|
|
|
|
|
std::string split3=STORY_DIALOG[dialogNumber].substr(STORY_DIALOG[dialogNumber].find('\n',STORY_DIALOG[dialogNumber].find('\n')+1)+1,STORY_DIALOG[dialogNumber].length()-(STORY_DIALOG[dialogNumber].find('\n',STORY_DIALOG[dialogNumber].find('\n')+1)+1)); |
|
|
|
|
|
|
|
messageBoxSpeaker=split2; |
|
|
|
messageBoxText=""; |
|
|
|
messageBoxText=""; |
|
|
|
messageBoxRefText=STORY_DIALOG[dialogNumber]; |
|
|
|
messageBoxRefText=split3; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|