generated from sigonasr2/CPlusPlusProjectTemplate
Intro text scene added
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
37ce031cb9
commit
cf26ac0f1f
@ -23,7 +23,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
GAMESTATE GAME_STATE=CUTSCENE_1;
|
GAMESTATE GAME_STATE=CUTSCENE_1;
|
||||||
int textInd=0;
|
int textInd=0;
|
||||||
|
int cursorX=0;
|
||||||
int transitionTime=0;
|
int transitionTime=0;
|
||||||
|
int frameCount=0;
|
||||||
float elapsedTime=0;
|
float elapsedTime=0;
|
||||||
const float TARGET_RATE = 1/60.0;
|
const float TARGET_RATE = 1/60.0;
|
||||||
std::string CUTSCENE_CONSOLE_TEXT = "";
|
std::string CUTSCENE_CONSOLE_TEXT = "";
|
||||||
@ -44,25 +46,38 @@ public:
|
|||||||
updateGame();
|
updateGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetKey(olc::A).bPressed) {
|
||||||
|
}
|
||||||
|
|
||||||
drawGame();
|
drawGame();
|
||||||
// called once per frame
|
// called once per frame
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGame(){
|
void updateGame(){
|
||||||
|
frameCount++;
|
||||||
switch (GAME_STATE) {
|
switch (GAME_STATE) {
|
||||||
case CUTSCENE_1:{
|
case CUTSCENE_1:{
|
||||||
if (textInd<STORY_TEXT1.length()) {
|
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) {
|
if (GetTextSize(CUTSCENE_CONSOLE_TEXT).x>WIDTH-32) {
|
||||||
int tempIndex=textInd;
|
int tempIndex=textInd;
|
||||||
while (CUTSCENE_CONSOLE_TEXT[--tempIndex]!=' ') {
|
while (CUTSCENE_CONSOLE_TEXT[--tempIndex]!=' ') {
|
||||||
CUTSCENE_CONSOLE_TEXT.erase(tempIndex);
|
CUTSCENE_CONSOLE_TEXT.erase(tempIndex);
|
||||||
|
cursorX--;
|
||||||
}
|
}
|
||||||
CUTSCENE_CONSOLE_TEXT.erase(tempIndex++);
|
CUTSCENE_CONSOLE_TEXT.erase(tempIndex++);
|
||||||
CUTSCENE_CONSOLE_TEXT+='\n';
|
CUTSCENE_CONSOLE_TEXT+='\n';
|
||||||
|
cursorX=0;
|
||||||
while (tempIndex<textInd) {
|
while (tempIndex<textInd) {
|
||||||
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[tempIndex++];
|
CUTSCENE_CONSOLE_TEXT+=STORY_TEXT1[tempIndex++];
|
||||||
|
cursorX++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,10 +88,13 @@ public:
|
|||||||
void drawGame(){
|
void drawGame(){
|
||||||
switch (GAME_STATE) {
|
switch (GAME_STATE) {
|
||||||
case CUTSCENE_1:{
|
case CUTSCENE_1:{
|
||||||
if (textInd<STORY_TEXT1.length()) {
|
|
||||||
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1});
|
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);
|
if (textInd<STORY_TEXT1.length()) {
|
||||||
|
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;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user