So far I have the code
- (void)CreatenewBlock:(int)blockCountToSpawn
{
for (int i=0; i != blockCountToSpawn; i++)
{
theBlockxCord = arc4random() % 4;
theBlockyCord = arc4random() % 4;
NSLog(@"New Block with Cords (%i, %i)",theBlockxCord, theBlockyCord);
}
}
This loops until it reaches the anount of blockCountToSpawn
This works exactly how I want it to but I want to set theBlockxCord to a new variable each time. So the end result would be something like:
theBlockxCordOfBlock1=2
theBlockxCordOfBlock2=4
theBlockxCordOfBlock3=1
theBlockxCordOfBlock4=3
Instead of theBlockXCord being overwritten each time.
For bonus points, Is there a single way to call of them maybe in an array so I don’t have to keep doing this:
if (theBlockxCordOfBlock1 == 2 || theBlockxCordOfBlock3 == 2 ..etc)
{
do stuff..
}
You can use C arrays or an NSMutableArray. You will have to convert the
ints toNSNumbers before you can add it to the array.if you want to search for
2then do thisor
EDIT