The Dink Network

Reply to Re: Random guestion (I love creating foolish 2-sided titles)

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
June 16th 2003, 01:55 PM
wizardb.gif
Phoenix
Peasant He/Him Norway
Back from the ashes 
Dat's not how random(); works. So.. here's what you would've wanted:

(Can be done easier, without variables, but I prefer them, as they make it all more clear (or more difficult, depending on your level of DinkC understanding.. ))

//Min Xposition
int &min_x = 350;
//Max position
int &max_x = 370;

//Due to the way random() works, subract the min
//value off the max value. (See Ted Shutes Annotated
//DinkC for more information)

int &actual_x = &max_x;
&actual_x -= &min_x;

//Now that we have values that are useful, let's randomize, w00t.

int &x_pos = random(&actual_x, &min_x);

----------

Just to clarify, you could basically just do

int &x_pos = random(20, 350)

WHY? you ask?

Because what dink does is that it finds a number between 0 and 19 and then adds 350 to that number. Do your homework before you use a command, hehe. I recommend, as earlier said in this post, the super Annotated DinkC document by Ted Shutes.