0

breakout: drand() just return positive number, so the ball only begins moving to right. Right?

or is there some way to make de ball go to left randomly?

1

You can multiply the output of drand by a number to get a random number between 0 and that number.

You can also set the range of the random number function to extend to be negative by subtracting from your negative number.

If you want a random number between -x and x, and y is the number drand48 output, you can do:

y * 2x - x

Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .