The Dink Network

Random guestion (I love creating foolish 2-sided titles)

June 16th 2003, 12:24 PM
spike.gif
I need to create an object in between 350 - 370, but when I use random(350,370); the object I wanna create appears just somewhere on the screen.
Wazrong?
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.
June 18th 2003, 12:28 AM
wizardg.gif
Paul
Peasant He/Him United States
 
Sigh. I wish this board handled & better. I'm getting a wierd R thing ( ℜ ) instead of the variable name &real_x.
June 23rd 2003, 02:27 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
ARRRGGGH!! I HATE IT WHEN SOMEONE WRITES "GUESTION" INSTEAD OF "QUESTION"!! Ehrm...