I'm developing my first game app for the iphone, and I'm still a bit nooby in objective-c.
The game is coming along fine but i'm stuck on a little problem...
I want to make it so that for every 20 kills, you get +1 life, I know how to do that but with poorly written code such as this...:
switch (kills) {
case 20:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 40:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 60:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 80:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 100:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 120:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 140:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 160:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 180:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 200:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
and so on.... I don't want to keep writing this till infinity lol
I know for a fact that this is an improper way to write the code. Can anyone give me a proper code for every 20 kills = +1 life. I would probably spot on and understand how the code works too.