Game Development Reference
In-Depth Information
Each of the tests is again an instance of the Game interface, and the actual test logic is
implemented in the form of a Screen contained in the Game implementation of the test, as in the
previous chapter. Only the relevant portions of the Screen will be presented, to conserve some
pages. The naming conventions are again XXXTest and XXXScreen for the GLGame and Screen
implementation of each test.
With that out of your way, it's time to talk about vectors.
In the Beginning . . . There Was the Vector
In Chapter 7, you learned that vectors shouldn't be mixed up with positions. This is not entirely
true, as we can (and will) represent a position in some spaces via a vector. A vector can actually
have many interpretations:
ï?® Position : We already used this in the previous chapters to encode the
coordinates of our entities relative to the origin of the coordinate system.
ï?® Velocity and acceleration : These are physical quantities you'll hear about
in the next section. While you are likely used to thinking about velocity and
acceleration as being a single value, they should actually be represented as
2D or 3D vectors. They encode not only the speed of an entity (for example, a
car driving at 100 km/h), but also the direction in which the entity is traveling.
Note that this kind of vector interpretation does not state that the vector is
given relative to the origin. This makes sense, since the velocity and direction
of a car are independent of its position. Think of a car traveling northwest
on a straight highway at 100 km/h. As long as its speed and direction don't
change, the velocity vector won't change either, while its position does.
ï?® Direction and distance : Direction is similar to velocity but generally lacks
physical quantity. You can use such a vector interpretation to encode states,
such as this entity is pointing southeast . Distance just tells us how far away,
and in what direction, a position is from another position.
Figure 8-1 shows these interpretations in action.
Figure 8-1. Bob, with position, velocity, direction, and distance expressed as vectors
Figure 8-1 is, of course, not exhaustive. Vectors can have a lot more interpretations. For our
game development needs, however, these four basic interpretations suffice.
 
Search WWH ::




Custom Search