Chapter    7

Game Object Types

In the previous chapters, you saw how to create a game world that contains a few different game objects, such as a cannon and a ball. You also saw how to let game objects interact with each other. For example, the ball object updates its color according to the color of the cannon. In this chapter, you will add falling paint cans to the game world. However, before you can do that, you have to reexamine how to create and manage objects in Swift. I will introduce the class concept as a means to create multiple game objects of a certain type. Then, you will apply the class concept to other parts of the Painter game application. Furthermore, you will learn how to incorporate randomness in your games.

Creating Multiple ...

Get Swift Game Programming for Absolute Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.