Game Development Reference
In-Depth Information
The function does the following:
1.
If the object is visible, it continues with the update, otherwise it returns.
2.
Checks the max z boundary to see if the object is outside it. If it is, and it
is going farther outside the boundary, then it reverses the z component of
the object's velocity. Then it checks the minimum z boundary to see if the
object is outside it. If it is, and it is going farther outside the boundary, then it
reverses the z component of the object's velocity.
3.
Repeats step 2 for the x boundary and reverses the x component of the
object's velocity instead of the z component.
Finally, an example of an arena object that we use in a later hands-on example in this chapter is
shown in Figure 8-1 .
Figure 8-1. An example of an arena object
Overview of Artificial Intelligence
The way complex artificial intelligence (AI) is generally applied in video games is through the
use of the finite state machine. A finite state machine consists of a set of states that represents
the behavior of the person, entity, or vehicle you want to simulate. Each state contains code to
implement this behavior and checks to see if there is a change in the game conditions that will have
to result in a change of state. If there needs to be a change of state, then the finite state machine
sets the current executing state to the one specified by the previous state, based on the previous
state's transition rules.
For example, let's say you want a player to be able to control a squad of robots and have these
robots perform specific tasks according to what command the player sends the robots. The
behaviors which the player can select from are
Retreat
Patrol
Attack Enemy
 
Search WWH ::




Custom Search