Author Topic: Help With Programming  (Read 465 times)

RussianVodka

  • Hydlaa Notable
  • *
  • Posts: 689
    • View Profile
Help With Programming
« 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.

Code: [Select]

//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.



Q: How many Planeshifters does it take to expalin a simple concept to a newb?
A: Six. Five to argue on who\'s explanation is right, and Moogie to lock the thread.

RussianVodka

  • Hydlaa Notable
  • *
  • Posts: 689
    • View Profile
(No subject)
« Reply #1 on: February 20, 2005, 03:49:34 am »
Anyone?



Q: How many Planeshifters does it take to expalin a simple concept to a newb?
A: Six. Five to argue on who\'s explanation is right, and Moogie to lock the thread.

Clover

  • Hydlaa Resident
  • *
  • Posts: 121
    • View Profile
(No subject)
« Reply #2 on: February 20, 2005, 03:56:27 am »
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.
Ordo Illuminatis
Master in the House of Shadow
Official Tavern Kitty

__Taking an extended leave of absense from PS.