Hardcore Mode

Players will eventually become familiar with the speed of the obstacles. With a bit of practice, they’ll figure out the timing and rack up dozens of points. You want to provide more a challenge. For every 5 points a player scores, you should add 1 to the groundSpeed. The modulus operator provides a convenient way to keep count:

if ((self.score % 5) == 0) {    self.groundSpeed++}

Reading aloud, you can pronounce the percentage sign as “modulo” or use the colloquial term “mod.” In this case, score mod 5 returns a 0 only when score is a multiple of 5. After you update the integer, display it by updating the text property of self.scoreText.

There’s one final task to accomplish in the blockRunner method. ...

Get Learning Swift™ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.