Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,089 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
startup function problem for my birds #123069
04/11/07 11:52
04/11/07 11:52
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
I am making a startup code for my birds to fly over the screen. My problem is this:
I want to be able to randomly let the birds appeare on the screen, at the same place as the other bird was before but not with the same time between them. As it is now the birds comes out on the screen every 7 seconds.
I have tried
sleep(7) + random(100);
and
sleep(7 + random(100));
but none of these did the trick.
I want them to come not regular...if you get my drift..I have marked with red where I tried it.
What am I doing wrong? The code works fine, only need to do what I asked with it.
Does anyone know a solution to my problem?

Code:

function lag_fugler6back_startup()//blue bird oppsite way
{
sleep (7); // wait until the level is loaded
while (1)
{
temp.x =500; //original -1000
temp.y = -400 ;//+ random (3000);//original 1000
temp.z = -250;//+ random (500); //original 500

ent_create (crow_mdl, temp.x,flytt3_fugl_motsattvei);
sleep (7); // generate a birds <-- I want to change this?
}
}



Last edited by Fiskekona; 04/11/07 11:54.

Programmer in training... Own GameStudio Commerical 6.50
Re: startup function problem for my birds [Re: Fiskekona] #123070
04/11/07 12:12
04/11/07 12:12
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
it's: sleep(7 + random(100));

are you sure you want it to be 100 though?
that would be more than a minute. but... try it.


~"I never let school interfere with my education"~
-Mark Twain
Re: startup function problem for my birds [Re: Germanunkol] #123071
04/11/07 12:20
04/11/07 12:20
Joined: Apr 2006
Posts: 160
DerLateinProfi Offline
Member
DerLateinProfi  Offline
Member

Joined: Apr 2006
Posts: 160
Germanunkol is right, do you really want it to be 100??? Think about this:

sleep(x); //X= second
wait(x); //X= 1/16 second

I think it was so!?! I hope it'll help.


DerLateinProfi


If there's a god He's watching can he give a ray of hope so much pain and so much sorrow www.lpp1991.de.vu
Re: startup function problem for my birds [Re: Germanunkol] #123072
04/11/07 12:25
04/11/07 12:25
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
thanks that did the trick...
I have changed it to
sleep(7 + random(50));
and it did what I wanted. And you was right...it was to much time to wait with 100....


Programmer in training... Own GameStudio Commerical 6.50
Re: startup function problem for my birds [Re: Fiskekona] #123073
04/11/07 12:48
04/11/07 12:48
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
sleep(x); is old syntax, use wait(-x); instead.

wait(-x); => waits x seconds

your code would be:
wait(-1 * (7 + random(50)));

Last edited by Thunder; 04/11/07 12:53.
Re: startup function problem for my birds [Re: Xarthor] #123074
04/11/07 16:35
04/11/07 16:35
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Uh, sorry, I forgot to add that, yeah.
sleep(1); will still work now, but not any more in the newer editions, is that right? yeah, wait(-7) replaces sleep(7) now...


~"I never let school interfere with my education"~
-Mark Twain
Re: startup function problem for my birds [Re: Xarthor] #123075
04/15/07 19:53
04/15/07 19:53
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
i will change that...every sleep to wait...thanks...


Programmer in training... Own GameStudio Commerical 6.50

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