Hey, for part of my game, I will be making a story part, and an rpg part. For the story part, i've designed it so that text will be displayed using a typewriter effect, you wait for that to stop, wait something like 5 seconds then it clears that and goes onto the next string. Well, i've tried while loops, do loops, if statements and even switches, but it's not working.
The closest i've come to it actually working is with while loops, this is an example of the closest i've come to making it work:
while (progress == 0)
{
if (timer.GetElapsedTime() > 0.01 && character < str.length())
{
timer.Reset();
character++;
text.SetText( str.substr(0, character) ) ;
App.Clear();
App.Draw(text);
App.Display();
}
if (character == str.length())
{
sf::Sleep(5);
progress = 1;
}
}
That piece of code will go through the string (str) and display it letter by letter, and this works. To then get it out of the loop, I then put an if statement to know when it's finished and put progress to 1, to make it get out of the loop, and then carry on with another while loop where it will be "while (progress == 1)".
The thing is, it stops all together after progress = 1 and doesn't exit the loop. To make sure that it did actually make progress 1, i did this:
if (character == str.length())
{
sf::Sleep(5);
std::cout << "Test";
progress = 1;
std::cout << progress;
}
and it actually put test, and 1 to the console but just stopped dead :/
If anyone could tell me what I'm doing wrong, or come up with another way round it, i'd be thrilled!
When i've made this, I'll be submitting it to the forums, with the source code, as other people's source code has really helped me learn, and i wanna give back to the community
aBallofWin