Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, SBGuy, TipmyPip, ozgur), 923 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Counter #210147
06/08/08 11:33
06/08/08 11:33
Joined: Oct 2007
Posts: 27
S
Skeksis Offline OP
Newbie
Skeksis  Offline OP
Newbie
S

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 Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
When a new round start call a function which does something like the following:
Code:
function start_NewRound()
{
  seconds = 120;
  count_down();
}


btw:
Instead of sleep(x); use wait(-x);
Because sleep is old syntax

Re: Counter [Re: Xarthor] #210161
06/08/08 13:25
06/08/08 13:25
Joined: Oct 2007
Posts: 27
S
Skeksis Offline OP
Newbie
Skeksis  Offline OP
Newbie
S

Joined: Oct 2007
Posts: 27
That worked, thanks for the help, I should have been able to figure it out myself.

Re: Counter [Re: Skeksis] #210208
06/08/08 23:31
06/08/08 23:31
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
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.
Re: Counter [Re: DJBMASTER] #210232
06/09/08 07:35
06/09/08 07:35
Joined: Oct 2007
Posts: 27
S
Skeksis Offline OP
Newbie
Skeksis  Offline OP
Newbie
S

Joined: Oct 2007
Posts: 27
I didn't try running it with sleep, I changed it to wait(-1), The only reason it had sleep in the script I posted is because I copied it from the original file and not from the file in my project.

Re: Counter [Re: Skeksis] #210238
06/09/08 08:29
06/09/08 08:29
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
hypothetical error event: multiple count_down() functions in engine's function list?
solvent / insurance: one instance only? proc_kill?
count_down()
count_down()
count_down()
count_down()
count_down()
count_down()
// close on n not down to other n
(Of end and beginning, Mistress Cosmos, is blind, persistent, and uncaring, with respect to primates, appendages, and digits.)


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1