Game Development Reference
In-Depth Information
Chapter 28
Intelligent Enemies
28.1 Introduction
As a next step in developing our game, let us introduce some peril to the player
by adding dangerous enemies. If the player touches an enemy, the player dies. The
enemies are generally not controlled by the player (that would make it too easy).
Therefore, we need to define some kind of smart (or stupid) behavior. We do not
want these enemies to be too smart either: 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
we can build different types of enemies that exhibit different types of behavior. As a
result, the player will have different gameplay options, and has to develop different
strategies to complete the level.
Defining the behavior of an enemy can lead to some very complex code, with
many different states, reasoning, path planning and much more. We will show a few
different types of enemies in this chapter: a rocket, a sneezing turtle (seriously),
sparky, and a couple of different patrolling enemies. In this chapter, we will not yet
deal with how the player should interact with the enemies. We will only define their
basic behavior.
28.2 The Rocket
One of the most basic enemies is the rocket. A rocket flies from one side of the
screen to the other side, then reappears after some time has passed. If the player
comes in contact with the rocket, the player dies. Inside the level description, we
indicate with the 'r' and 'R' characters that a rocket enemy should be placed inside
a level. For example, see this level description:
 
Search WWH ::




Custom Search