Gamestudio Links
Zorro Links
Newest Posts
Camera always moves upwards?
by clonman. 11/13/25 14:04
brokerCommand PLOT_HLINE parameters
by M_D. 11/13/25 10:42
ZorroGPT
by TipmyPip. 11/10/25 11:04
Training with the R bridge does not work
by frutza. 11/05/25 00:46
Zorro 2.70
by opm. 10/24/25 03:44
Alpaca Plugin v1.4.0
by TipmyPip. 10/20/25 18:04
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Grant, AndrewAMD, ozgur, Quad, TipmyPip), 29,980 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sheliepaley, Blueguy, blobplayintennis, someone2, NotEBspark
19177 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Loop for a fixed amount of seconds #442512
06/24/14 04:52
06/24/14 04:52
Joined: Jun 2013
Posts: 108
Alberta, Canada
C
CanadianDavid Offline OP
Member
CanadianDavid  Offline OP
Member
C

Joined: Jun 2013
Posts: 108
Alberta, Canada
Any suggestions for accurately running a while loop for a given amount of seconds without holding up the loop by using a negative wait value (ie: without using wait(-1))?

Re: Loop for a fixed amount of seconds [Re: CanadianDavid] #442515
06/24/14 06:38
06/24/14 06:38
Joined: Mar 2003
Posts: 1,524
Canada
Stansmedia Offline
Serious User
Stansmedia  Offline
Serious User

Joined: Mar 2003
Posts: 1,524
Canada
Something like this maybe?

Code:
var number;

function wait_seconds()
{
    wait(-3);
    number = 1;
}

function mything()
{
    number = 0;
    wait_seconds();
    while(number != 1)
    {
        //do stuff
        wait(1);
    }
}



Decessus - 80% done. 100% abandoned.
GET MY ANDROID GAME! https://play.google.com/store/apps/details?id=com.lasertrain.zspinballfree&hl=en
Re: Loop for a fixed amount of seconds [Re: Stansmedia] #442517
06/24/14 08:14
06/24/14 08:14
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
a local variable can do the same work with less code.

Code:
function fnc3secs ()
{
   var clock = total_ticks + 48; // 3 sec * 16 ticks/sec
   while ( clock > total_ticks )
   {
      wait(1);
   }
}


Re: Loop for a fixed amount of seconds [Re: txesmi] #442553
06/25/14 07:13
06/25/14 07:13
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Code:
var timer=0; 
while(timer<3) //3 seconds
{
   timer+=time_step/16;
   wait(1);
}



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

Gamestudio download | 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