Im making an interactive fiction or some sort
and as the title says
is it possible to disable text output delay(sleep) if you press enter or any assigned key?
like in a game (pokemon,etc.)
during conversations you can press 'B' or 'A' to show the texts immediately.
here's my code so far in delaying text output.
1 2 3 4 5 6
char x[]="Show this text slowly press enter to skip text delay";
for (int i=0;i<sizeof(x);i++)
{
std::cout<< x [i];
Sleep(100);
}
it's annoying to wait for all those lines to be outputted (but im keeping it for some sort of effects :P)
char x[]="Show this text slowly press enter to skip text delay";
for (int i=0;i<sizeof(x);i++)
{
std::cout<< x [i];
if (GetAsyncKeyState(VK_RETURN)==0)
{
Sleep(100);
}
}
is this right?
i have no idea where i put that sorry lol
i just started learning c++
1. get the first character in the string
2. output the character
3. check if the Return key is pressed, if it is not pressed, Sleep. If it is pressed, don't Sleep.
4. do it again for the next character in the string until the entire string is output
Now what you want it to do:
1. get the first character in the string
2. output the character
3. check if the Return key is pressed, If it is not pressed, Sleep. If it is pressed, don't Sleep, and don't sleep anymore.
4. output the rest of the string.
Notice if you hold down the Return key it quickly outputs the rest of the string, right now you are checking for each letter if the Return key is being pressed.