Chapter    25

Intelligent Enemies

As the next step in developing the Tick Tick game, let’s introduce some peril to the player by adding dangerous enemies. If the player touches an enemy, the player dies. The enemies generally aren’t controlled by the player (that would make it too easy). Therefore, you need to define some kind of smart (or stupid) behavior. You don’t want these enemies to be too smart: the player should be able to complete the level. After all, that is the goal of playing a game: winning it. What is nice is that you can build different types of enemies that exhibit different types of behavior. As a result, the player has different gameplay options and must develop different strategies to complete the level.

Defining the behavior ...

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.