Hi I'm learning Objective C (still). I create my own little projects for me so I can understand Obj C better. I created a little Battle Ship guessing game which is the computer playing against it's self guessing 2 random numbers. If they match the game ends.
I would like to slow down the the command line response to 1 guess every second so I can see the game slowly play out but I don't know how yet. Could one of you direct me to that information or show me how to add it. here is my code so far.
I would like to slow down the the command line response to 1 guess every second so I can see the game slowly play out but I don't know how yet. Could one of you direct me to that information or show me how to add it. here is my code so far.
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int comA, comB, count;
count = 1;
while(comA != comB)
{
NSLog(@"--------");
comA = arc4random() % 20;
comB = arc4random() % 20;
NSLog(@"ComA guessed %i and comB gueesed %i", comA, comB);
if (comA == comB){
NSLog(@"Com_A sank your ship in %i moves", count);
break;
}
NSLog(@"--------");
comB = arc4random() % 20;
comA = arc4random() % 20;
NSLog(@"ComB guessed %i and ComA says it's %i", comB, comA);
if (comB == comA){
NSLog(@"Com_B sank your ship in %i movies", count);
break;
}
count++;
}
NSLog(@"End of game_ it took %i rounds to kill you", count);
[pool drain];
return 0;
Thanks in advance!
-Lars
}