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?
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
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.