Aug 22, 2012 at 1:13pm
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...
Aug 22, 2012 at 1:15pm
First we need to know if the app have load time at all. Else we would have to fake the load bar
Aug 22, 2012 at 1:21pm
there is none it's just an effect for my project...thnx
Aug 22, 2012 at 1:31pm
Why on Earth would you want a fake loading screen!?
Aug 22, 2012 at 1:36pm
like i said its just an effect...to make my project more creative...
Aug 22, 2012 at 2:01pm
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 Aug 22, 2012 at 2:03pm
Aug 22, 2012 at 2:16pm
thank you so much this will help so much...very much appreciated...
Aug 22, 2012 at 3:01pm
If youre on windows i would recomend using Sleep(). It's very simple, but your program will be platform dependent
Aug 22, 2012 at 7:43pm
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 Aug 22, 2012 at 8:13pm
Aug 23, 2012 at 3:30am
^You need windows.h for Sleep().
Aug 23, 2012 at 4:44am
^Whoops, you're right. ( *** BRAIN FART *** ) !!