Wait() problem.

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>

using namespace 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();
}


Edit: Here's a video:

http://www.youtube.com/watch?v=Cc1yUjrwXwg
Last edited on
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>

using namespace 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();
}
closed account (Gz64jE8b)
Blackavar got it in one, your text will only "move" when the black lines hit the bottom of the screen.

You can see what we mean by replacing the black line with a word:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <Windows.h>

using namespace std;

int main()
{ 
	cout << "\n\n\n\n\n\n\n\n\nTest";

	for (int i = 0; i < 25; i ++)
	{
			cout << endl << "Hello";
			Sleep(150);
	}
	
	cin.get();
}
That did the trick. Thanks!
Topic archived. No new replies allowed.