Skip to content

Instantly share code, notes, and snippets.

@alinradut
Created April 17, 2011 18:32
Show Gist options
  • Save alinradut/924329 to your computer and use it in GitHub Desktop.
Save alinradut/924329 to your computer and use it in GitHub Desktop.
- (void)updateCorrectKeysPressed {
correctKeysPressed_++;
correctKeysPressedThisGame_++;
// update the current score, 10 points for a correct key and 3 points for each consecutive correct key
score_ += 10 + (correctKeysPressedThisGame_ - 1) * 3;
if (correctKeysPressed_ && correctKeysPressed_ % 10 == 0) {
// compute the bonus based on consecutive correct keys
NSInteger bonus = score_ * ((float)correctKeysPressed_/200);
score_ += bonus;
NSString *achievement = [NSString stringWithFormat:@"%d keys in a row! (+%d)", correctKeysPressed_, bonus];
// show the achievement notification
[self achievementUnlocked:achievement];
}
[scoreLabel_ setString:[NSString stringWithFormat:@"Score: %d", score_]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment