Gamestudio Links
Zorro Links
Newest Posts
SGT_FW
by Aku_Aku. 11/30/26 08:19
Removing outliers from files
by JeyKey II. 11/29/26 10:01
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (AndrewAMD, rht, EvanTJ, JeyKey II, Quad), 12,772 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 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 Online
Senior Expert
Quad  Online
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