PlaneShift
Fan Area => The Hydlaa Plaza => Topic started by: RussianVodka on February 19, 2005, 10:35:32 pm
-
I was sitting in class being boared and whatching the broken clock, when I got the idea to make a timer program. So the other day I started making the \"engine\" if you will, and I came across this problem. Before I used the Sleep(###) comand (found in the windows.h library) to pause my programs. But while making this I\'ve realized that the command only stops the program externaly, while internaly it continues to run.
//Timer
#include
#include
int main()
{
int stoper = 0;
int sec = -1;
int min = 0;
int hour = 0;
while (stoper == 0)
{
sec = sec + 1;
if (sec == 60)
{
min = min + 1;
sec = 0;
}
else
{}
if (min == 60)
{
hour = hour + 1;
min = 0;
}
else
{}
cout << hour << \" Hours; \" << min << \" Minutes; \" << sec << \" Seconds.\\n\";
Sleep(1000);
}
return 0;
Anyways, instead of pausing the program for a second, it just does what looks like lowering the frame rate. What command can I use instead of Sleep(###)?
Note: This is only the counting part of the timer program... Once I get this thing figured out I\'m gona add external prompt commands that will let you choose weather to count up, count down, and when to stop counting.
-
Anyone?
-
I\'m not a C++ buff and I\'m sure there is a faster way, but could you grab the time and update it when the seconds goes up one.
while stopper == 0
if time == (time + 1)
and so on.