Video Game Design and Programming Concepts 120 Copyright Goodheart-Willcox Co., Inc. May not be reproduced or posted to a publicly accessible website. Name: ___________________________________________ Date: ____________________________________________ Class: ___________________________________________ direction determines the path the object will travel. Some game design software may use the term vector to describe the direction. This same car also has a speed attribute. Speed is how fast something is moving. In engineering and physics, speed is referred to as velocity. Both words have the same meaning, and speed is used more frequently in game programming. If the car is obeying the speed limit of 50 miles per hour (mph), it would have a speed attribute of 50 mph. To calculate speed, use the formula: velocity = distance ÷ time In the example of the car, the car travels a distance of 50 miles in one hour. The formula works out such that 50 miles ÷ 1 hour = 50 miles/hour, or 50 miles per hour (mph). Speed can change as the car is moving. The instantaneous speed is the exact speed the car is moving at the moment or instant you observe. If you drive down the street and a slow- moving bus gets in front of you, you will need to slow down. Your instantaneous speed might drop to 40 miles per hour until you can pass the bus. You may even speed up a bit to 60 miles per hour as you pass the bus. During your trip, your instantaneous speed may change as you drive through traffic and around corners. In the end, you may still have traveled 50 miles in one hour, but your instantaneous speed will have varied along the 50 mile journey. To change the instantaneous speed of the car, the driver must press the accelerator pedal to speed up or the brake pedal to slow down. This applies additional force to the car, as shown in Figure 10-2. To speed up, the car must accelerate. To slow down, the car must decelerate. Imagine that the car is stopped. A stopped car has no speed, or an instantaneous speed of 0. If the driver presses the accelerator pedal, the car begins to move. When observed two seconds later, it may be traveling at an instantaneous speed of 20 mph. Applying gas allowed the car to accelerate from 0 mph to 20 mph in two seconds. Speeding up or changing the instantaneous speed in the positive direction is acceleration. In other words, the object is moving faster. Acceleration is calculated using the formula: acceleration = distance ÷ time2 Goodheart-Willcox Publisher Figure 10-1. In this example, there are 32 possible directions the object can take. Of the possible directions, eight have been selected as possible solutions for the object. Blocks indicate possible directions Arrows indicate selected possible directions
Previous Page Next Page