I'm new to Objective-C, and for starters, I'm making a simple pong game.
To make the ball move at the beginning of a new round, I use
ballVelocity = CGPointMake(4 - arc4random() % 8,4 - arc4random() % 8);
However, the important part is precisely this:
4 - arc4random() % 8
However, there are several problems with this: in the first place, it really does not generate a random number. Only after I leave the simulator, then again open new numbers. Secondly, I want it to generate numbers between -4 and -2 or 2 and 4.
I look here and elsewhere for an hour and still can't find anything. I'm so used to PHP where it is much easier.
Thank. Again, I looked at other issues here, and the suggestions they give do not work as I want, or just confuse me.
source
share