Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,595 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: While statements [Re: ventilator] #320420
04/21/10 17:22
04/21/10 17:22
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Cool. I'll play around with them and see what works. You mentioned random run time...how does that affect the script/game?

Re: While statements [Re: Icarni] #320423
04/21/10 17:37
04/21/10 17:37
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
it depends on how often you call such functions. probably it doesn't matter much in your case but if you use this programming style a lot, you could get problems like very inconsistent frame times and jerks and so on. it better should be avoided especially if there is a shorter and nicer solution anyway. laugh

Re: While statements [Re: ventilator] #320430
04/21/10 18:19
04/21/10 18:19
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
yes it has random runtime but at best it can loop 10*10 = 100 times, considering that the heaviest stuff in the loop is random function, length diffrence of that loop is negligible.


3333333333
Re: While statements [Re: Quad] #320477
04/21/10 21:06
04/21/10 21:06
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
One more question about lists. Once I have told the program to make a list, how do I assign the numbers to my variables? IE X_1, X_2, etc...

Re: While statements [Re: Icarni] #320483
04/21/10 21:31
04/21/10 21:31
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
X_1 = numbers[0];
X_2 = numbers[1];
...
X_10 = numbers[9];

????

Re: While statements [Re: Widi] #320485
04/21/10 21:35
04/21/10 21:35
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Cool. Thanks!

Re: While statements [Re: Icarni] #320489
04/21/10 21:58
04/21/10 21:58
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
or use in your code direct the array (numbers[0]) instead of X_1.

Re: While statements [Re: Widi] #320570
04/22/10 17:52
04/22/10 17:52
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
Ok, so I still need a bit of help with this. I ran the script as ventilator wrote it above and the first thing I came up with is that 'index' was an undeclared identifier. I think I've pretty much gotten around that by either declaring it as a variable outside of the function, or using 'int index' inside the function. However, the numbers I'm getting back are not right. I get a few integers between 1 and 192, but I'm also getting 0's and -999, 999. Could I get a more detailed explanation of how the code works so that I can figure out what's wrong with it? Thanks!

Re: While statements [Re: Icarni] #320572
04/22/10 18:09
04/22/10 18:09
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
yes, sorry, i didn't test my script...

here is a corrected version:

Code:
void main()
{
	randomize();
	
	int n;
	int numbers[10];
	int array[192];
	for(n=0; n<192; n++) array[n] = n + 1;  // fill array with 1..192
	
	for(n=0; n<10; n++)
	{
	    int index = random((191-n)+1);
	    numbers[n] = array[index];
	    array[index] = array[191-n]; // remove the number from the array by replacing it with the last one in the array (the last one won't be accessed anymore)
	}
	
	printf("%d %d %d %d %d %d %d %d %d %d", numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6], numbers[7], numbers[8], numbers[9]);
	
}



Re: While statements [Re: ventilator] #320575
04/22/10 18:34
04/22/10 18:34
Joined: Apr 2010
Posts: 20
I
Icarni Offline OP
Newbie
Icarni  Offline OP
Newbie
I

Joined: Apr 2010
Posts: 20
ok, so where do I put my variable pointer? (IE: X_1 = , X_2 = , etc...)

Page 2 of 3 1 2 3

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