Random guestion (I love creating foolish 2-sided titles)
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?
Wazrong?
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.
(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.

Sigh. I wish this board handled & better. I'm getting a wierd R thing ( ℜ ) instead of the variable name &real_x.
ARRRGGGH!! I HATE IT WHEN SOMEONE WRITES "GUESTION" INSTEAD OF "QUESTION"!! Ehrm...