ok i am having a little trouble generating random numbers betwen a range. i want the number to be between 40 and SCREEN_X-40 and also be a factor of 20. I had it working, but i somehow screwed it up and saved over it and cant get it working.
this is what i have, but it is not doing #'s in the rt range
x = 20*((rand() % ((SCREEN_W-40)/20) +2 ));
40 <= x <= SCREEN_X - 40
0 <= x <= SCREEN_X - 80
therefore: (rand() % (SCREEN_X - 80)) + 40
that creates numbers in the rt range, but they are not factores of 20. also why is it SCREEN_X-80.
ok i figured it out
x=20*((rand() % (SCREEN_X - 80)/20) + 2);
thanks for your help