In this chapter, you will make the Painter game more interesting by giving the player a limited number of lives. If players miss too many paint cans, the game is over. The chapter discusses how to deal with that and how to display the current number of lives to the player. In order to do the latter, you will learn a few programming constructs for repeating a group of instructions several times.
Maintaining the Number of Lives
To introduce some danger and incentive to work hard in the game, you would like to limit the number of paint cans of the wrong color that the player can allow to fall through the bottom of the screen. The Painter7 example adds this kind of behavior to the game and uses a limit of five.
The choice ...
Get Swift Game Programming for Absolute Beginners 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.