Created
April 17, 2011 18:32
-
-
Save alinradut/924329 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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