Try converting RAND_MAXto float before adding to it.
curBall->x=((float)rand()/( ((float)RAND_MAX) +1))*(ww-1) +1;
et cetera. RAND_MAXoften equal INT_MAX, the largest value may contain an integer, adding 1 to it, while it is still considered an integer, pushing it along the integer limit.
Amber source
share