Game Development Reference

In-Depth Information

vehicle, we increment it by the velocity

'

s
x
and
y
components and

the deltaTime property.

If you export this example and test it, you

ll notice immediately

the car handles very differently, almost as if it were on ice. When

you turn at high speeds, the car continues in its original direction

for a time before eventually aligning itself with the new direction.

This is because by adding the vectors together with discrete
x
and

y
values, it takes a few passes of friction scaling to reduce the effect

of previous accelerations. Naturally, most cars don

'

tdrifttheway

this one does. With some additional complexity, you could factor

in the weight of the car to determine when the car

'

'

s velocity over-

comes its downward force (essentially, the car

'

straction)andso

get the best of both examples.

Review

We

'

'

ve covered a lot of material in this chapter, so let

s run through

'

a high-level reminder of everything we

ve learned:

The relationship of triangles to angle and distance problems

The trigonometric functions (sine, cosine, and tangent) and

their uses

The coordinate system inside Flash, including the 3D transform

system

How to manipulate objects in Flash

'

s 3D space

How to use perspective projection to create vanishing points

The difference between scalar and vector values in physics

The basics of classical mechanics in motion

—

velocity, acceleration,

friction, and inertia

How to apply simple 2D physics in ActionScript

How to use the new Vector3D class to simplify the process of

combining vectors

There is considerably more material in topics and on the Inter-

net to read about physics if you

re interested in doing more robust

simulations. There are links to a number of resources on this

book

'

'

s Web site.