Character
Graphics
Up to this point, only the
functionality of a character has been discussed. The reality is that
functionality is the only part that really matters, but game players will want
some sort of visual representation of their digital alter ego. With the power of
a 3-D modeler and the Graphics Core, you’ll have no problem tackling the
graphics portion of your characters.
Each character in your game can
perform specific actions. These actions are as follows: to walk, stand still,
swing a weapon, cast a spell, be hurt, and die. Each of these actions has a
specific animation, which is used in conjunction with a mesh to create a
character’s graphics component.
As you learn in the later
section “Creating a Character Controller Class,” each character’s
mesh is loaded into a cMesh object, and each animation is loaded into a
cAnimation object. Those two Graphics Core objects are unique to each character
in
your game (with multiple instances of the same character using only one mesh and
animation object). Your job is to load those meshes and animations and to render
the characters to the display at each frame.
Navigating Characters
Now that you’ve defined your
characters, it is time to put them in the world and move
them around. This is where you separate control systems between PCs and NPCs.
PCs,
being the characters directly controlled by the players, have the most options.
you have already witnessed the
player control system (which I like to call direct control) that I created.
Those demos enable you to move the player around using arrow keys and the mouse.
NOTE
First person and non-first person describes the viewpoint of the player. For
first-person games, the
player’s viewpoint is from the character’s eyes. Non-first-person games take a
different viewpoint—
from above, the side, or any other such angle.
For the first-person demos,
pushing the up arrow moves the player forward, pushing the down arrow moves the
player
backward, and pushing the left and right arrows moves the player left and right,
respectively. Moving the mouse rotates the viewpoint. As for a non-first-person
demo, the arrows move the character in the appropriate direction (press the up
arrow to move up, press the left arrow to move left, and so on).
Rarely does anything become
more complicated than using these control systems
when dealing with a PC. Things do get complicated, however, whenever your player
starts walking around bumping into other characters and objects (such as doors).
You’ve already seen how to perform collision detection of sorts, so that’s
really not
a big problem.
Things tend to get a little
more complicated for NPCs. No longer is the player
responsible for moving a character around the map; the game engine takes over.
You also can enable NPCs to walk around according to simple directions, but
instead of moving around the world like the PC, NPCs perform a basic set of
movement behaviors, as follows:
■ Stand still
■ Wander aimlessly around the entire level or specific area
■ Walk along a specified route
■ Follow a character
■ Evade a character
The preceding list of actions
is all you ever need to start, and because you have to
start somewhere, start at the most logical place—with the PC controls.