106 Video Game Design Foundations
Direction of travel for sprites is typically defi ned by compass directions:
North, South, East, and West. Some sprite character sets can have 16 direc-
tions of motion just for walking on a fl at surface, as shown in Figure 4-15.
Everything in a game frame is located with a coordinate system. The
coordinate system is very similar to the coordinate graphing you have done in your
math and science classes. It involves the X coordinates (left and right, horizontal
directions), Y coordinates (up and down, vertical directions) and Z coordinates
(depth or closer and farther directions). In 2D games the Z value is always 0.
If you remember Cartesian coordinates from your math class, moving to
the right of the origin, the value of X changes in the positive direction. When you
move up from the origin, the value of Y changes in the positive direction. The
coordinates of the origin are written as (0,0,0). This means X, Y, and Z all have a
value of zero. The X value is always fi rst, followed by the Y value and then the Z
value. Since the Z value is always zero in 2D games, it can be removed from the
coordinate set. Then, the origin is written (0,0), Figure 4-16.
If you move to a different point other than the origin, you need to iden-
tify where on the X and Y axis that point exists. If you locate the colored dot
on the graph in Figure 4-16, the coordinates are (5,3) or X = 5 and Y = 3.
The same concept of coordinates applies to game design, except the Y axis is
fl ipped in some game engines.
Figure 4-17 shows an image from The Games Factory 2. This shows
a 2D frame where the origin of the coordinate system (0,0) for the frame
start is the top-left corner. If the pointer moves
one pixel to the right along the X axis, the coor-
dinates are 1,0. If the pointer then moves one
pixel down along the Y axis, the coordinates are
1,1. To fi nd the total screen size, the pointer can
be moved to the bottom-right corner. Here, the
coordinate indicator would read 640,800 as
this screen size is 640 pixels wide and 800
pixels tall.
Also included in the concept of 2D depth
perception is parallax movement. To create
depth when a 2D character moves, designers
create a background from multiple background
maps. By layering these maps so closer objects
are in front of distant objects, the feeling of
depth is created. The designer then programs
these layered background maps to move at
different rates to simulate the movement you
see in nature. The map closest to the player
moves fastest. The map farthest from the player
moves slowest. Next time you play the classic
game Mario Brothers, look at how the back-
grounds move behind the action. You will build
a game with parallax later in this course.
+X
+Y
–X
–Y
(0,0)
(5,3)
Figure 4-16. This is the coordinate system used for 2D
games. The Z value is always zero. Some game engines fl ip
the negative and positive directions for the Y axis (negative
on top, positive on bottom).
CHEAT CODE: PARALLAX
Parallax describes how objects in the distance
seem to move more than objects in the
foreground. This creates a slight change of
perspective when the foreground object
moves. An easy way to practice this is to
hold one fi nger up as you point at an
object in the distance. Close one
eye at a time and the object in
the distance seems to jump to the other side of your fi nger.
Previous Page Next Page