Originally Posted By: EvilSOB
No problems, BUT, take a look at the time-calculations flowing
from seconds into hours. It's right, but Im sure there is a better way.


There is, and it's super simple:

Code:
void StopWatch(var* Hours, var* Minutes, var* Seconds)
{
    static var hours, minutes, seconds, running=0;
    if(running==0)
    {    //START StopWatch
        running = 1;
        hours=*Hours;    minutes=*Minutes;    seconds=*Seconds;
        while(running)
        {
            wait(1);
            seconds += (timer()/1000000);

            minutes += integer(seconds / 60);
            seconds = seconds % 60;

            hours += integer(minutes / 60);
            minutes = minutes % 60;
        }
        return;
    }
    //STOP StopWatch
    *Hours = hours;    *Minutes = minutes;    *Seconds = seconds;
    running=0;
    return;
}


No more if statements needed smile


Just so beginners understand, the mathematical operator "%" is called modulus. It calculates the remainder of a division operation.

Lets say we have a pile of 20 cookies. We want to serve the cookies at a party on plates, where each plate can hold 3 cookies. 20 / 3 equals 6.666666_, so we know there will be cookies left over, but how many? 20 % 3 equals 2, so there will be 6 plates with 3 cookies each and 1 plate with just 2 cookies. You'd better eat that serving before-hand... you don't want an upset guest!

Last edited by JMichalc; 03/24/09 02:16.