REVERSE time counting

Posted By: MDI

REVERSE time counting - 11/19/07 21:34

I know how to make timer who works like normal hronometr( withseconds and miliseconds), but how to get this reverse.
This i need for my game, where terrain makes timeout for moving further and in corner shows waiting time.

OK then to you all this is clear - any ideas? because i know when this is possible!
Posted By: MDI

Re: REVERSE time counting - 11/20/07 21:03

OK!! No problem! I think im solve this problem.
Have i say all is possible.
Posted By: Xarthor

Re: REVERSE time counting - 11/20/07 21:11

sorry for responding late, and although it seems that you have found a solution I'd like to post a possible solution for people who find this thread using the search function afterwards:

Basicly all you do is first setting the starting time and then subtract from it as long as it is above zero.
My example will use "seconds" as time measurement.
The variable "total_secs" stores the time in seconds which is still left.
My example does not take care of converting this to minutes.
Code:

// !!! Aware: C-Script Code !!!

var total_secs = 0;

function timer_start(_seconds)
{
total_secs = _seconds;

while(total_secs > 0)
{
wait(-1);
total_secs -= 1;
}
}

function timer_stop() //use this function to force the timer to stop
{
total_secs = 0;
}

// Start the timer like this. (example uses 2 minutes as start value)
timer_start(120);


Posted By: MDI

REVERSE time counting - 11/20/07 21:51

Thanks! This is very simple!
I done this in much more complex way - with seconds, miliseconds who use total_ticks and so on!
Although even no needs for something so complex if all can do very simly! OR NOT!
© 2024 lite-C Forums