What I want to do is the text to move up (like credits at the end of the movie).
The problem with my code is that there is a ~3 second pause before the text starts to move up. After that the Wait() function works correctly and adds new lines every 150ms.
How can I fix the code so that the text starts "moving" up as soon as the program starts?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <Windows.h>
usingnamespace std;
int main()
{
cout << "\n\n\n\n\n\n\n\n\nTest";
for (int i = 0; i < 25; i ++)
{
cout << "\n";
Sleep(150);
}
cin.get();
}
The text starts "moving" up when there's not enough space left in your window. The delay you are seeing is (0.15 seconds)*( # of blank lines after "Test"'s first appearance ). Assuming you know exactly what size window you'll be working with, you can just put the right number of newlines before starting your loop. Looking at your video, I think you want about 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <Windows.h>
usingnamespace std;
int main()
{
cout << "\n\n\n\n\n\n\n\n\nTest";
cout << "\n\n\n \n\n\n \n\n\n \n\n\n \n\n\n";
for (int i = 0; i < 25; i ++)
{
cout << "\n";
Sleep(150);
}
cin.get();
}