can any one help me? i want to make something like this
******
******
then after 2 sec it will become like this
************
************
then again after 2 sec it will progress until it reaches the end of line...
thanks for anyone who will help me in advance...
First we need to know if the app have load time at all. Else we would have to fake the load bar
there is none it's just an effect for my project...thnx
Why on Earth would you want a fake loading screen!?
like i said its just an effect...to make my project more creative...
Fair enough, though I'd hope a program would open up fast as possible.
I can't remember if C++ has a sleep function or not. I'll write one for you. Let's call it Wait(). You'll need to include the ctime header.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
#include <ctime>
using namespace std;
void Wait(int seconds)
{
bool waiting = true;
int fc, cc; // First click, current click
fc = clock();
while(waiting)
{
cc = clock();
if( ((cc - fc) / CLOCKS_PER_SEC) > seconds )
break;
}
}
int main(int argc, char *argv[])
{
cout << "Hello ";
Wait(2);
cout << " world!";
}
|
Obviously the bit you'd need is the Wait function. I just included the main to show it working.
If you want it in a loading bar, just put it in a loop or something, printing out an asterisk at each iteration.
Note: It's a quick and dirty function, I'm afraid. Just don't do anything silly like pass -1 into it. ;-)
Last edited on
thank you so much this will help so much...very much appreciated...
If youre on windows i would recomend using Sleep(). It's very simple, but your program will be platform dependent
Ok, so the most simple way of doing this is...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
cout << "\n\n *\n *";
Sleep(500);
system("cls");
cout << "\n\n **\n **";
Sleep(500);
system("cls");
cout << "\n\n ***\n ***";
Sleep(500);
system("cls");
cout << "\n\n ****\n ****";
//Etc, your code
cin.sync(); cin.ignore();
}
|
Last edited on
^You need windows.h for Sleep().
^Whoops, you're right. ( *** BRAIN FART *** ) !!