Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDynamite Andy

Posted 16 March 2013 - 05:41 AM

the third bug is that the rand() function doesnt seem to be working for getting a value between 8 and 5. <- ball.cpp

The line:

 

case 1: velocity.set((rand()%(8-5)+5),-rand() % 5 + 1); // Rand is broken. Why?

Will set X between 5 and 7, since rand()%(8-5) will return 0, 1, or 2, and adding it to 5 will give 5, 6, or 7.

Is that what you are seeing?  You need to make it rand()%4 + 5 if you want a random value from 5 to 8.

 

What was actually happening is that it was still somehow being set between 3 - 8 and i wasnt sure why.

 

I'll be sure to try get these fixes into place tomorrow morning,.

 

EDIT: rand is still returning values less than the minimum value.


#1Dynamite Andy

Posted 15 March 2013 - 04:50 PM

the third bug is that the rand() function doesnt seem to be working for getting a value between 8 and 5. <- ball.cpp

The line:

 

case 1: velocity.set((rand()%(8-5)+5),-rand() % 5 + 1); // Rand is broken. Why?

Will set X between 5 and 7, since rand()%(8-5) will return 0, 1, or 2, and adding it to 5 will give 5, 6, or 7.

Is that what you are seeing?  You need to make it rand()%4 + 5 if you want a random value from 5 to 8.

 

What was actually happening is that it was still somehow being set between 3 - 8 and i wasnt sure why.

 

I'll be sure to try get these fixes into place tomorrow morning,.


PARTNERS