|
Counter
#210147
06/08/08 11:33
06/08/08 11:33
|
Joined: Oct 2007
Posts: 27
Skeksis
OP
Newbie
|
OP
Newbie
Joined: Oct 2007
Posts: 27
|
This is probably going to sound really noobish, but I'm not much of a programmer. Bassically I'm working on a simple boxing game, I'm using the script below as a timer for the rounds, it counts down 2 minutes, when it reaches zero the next round starts. The problem is I can't seem to reset the timer at the start of each round, it just stays at zero, I hope that made sense.
string time_str; string temp_str;
var seconds = 120; // number of seconds to be counted down var temp_seconds;
function count_down()
{ while(seconds > 0)
{ sleep (1); seconds -= 1; temp = int(seconds / 60); // compute the number of minutes str_for_num(time_str, temp); str_cat (time_str, " : "); temp_seconds = seconds - temp * 60; // compute the remainder (the number of seconds) str_for_num(temp_str, temp_seconds); if (temp_seconds < 10) { str_cat (time_str, "0"); // add a zero (if needed) } str_cat (time_str, temp_str); } }
|
|
|
Re: Counter
[Re: Skeksis]
#210160
06/08/08 13:09
06/08/08 13:09
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
When a new round start call a function which does something like the following:
function start_NewRound()
{
seconds = 120;
count_down();
}
btw: Instead of sleep(x); use wait(-x); Because sleep is old syntax
|
|
|
Re: Counter
[Re: Skeksis]
#210208
06/08/08 23:31
06/08/08 23:31
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
Did it even run with "sleep"? I thought the engine would have refused to run with the old syntax, are you using A7?
Last edited by DJBMASTER; 06/08/08 23:32.
|
|
|
|