Game Development Reference
In-Depth Information
instead of left and right, it would model the Y-axis. Adding a positive number (or
subtracting a negative number) would move the knight up the number line, and subtracting
a positive number (or adding a negative number) would move the knight down. When we
put these two number lines together, we have a Cartesian coordinate system like in Figure
12-7.
The 0, 0 coordinate has a special name: the origin .
Math Tricks
Subtracting negative numbers or adding negative numbers seems easy when you have a
number line in front of you, but it can be easy when you only have the numbers too. Here
are three tricks you can do to make evaluating these expressions by yourself easier to do.
Trick 1: "A Minus Eats the Plus Sign on its Left"
The first is if you are adding a negative number, for example; 4 + -2. The first trick is "a
minus eats the plus sign on its left". When you see a minus sign with a plus sign on the left,
you can replace the plus sign with a minus sign. The answer is still the same, because
adding a negative value is the same as subtracting a positive value. 4 + -2 and 4 - 2 both
evaluate to 2.
Figure 12-8: Trick 1 - Adding a positive and negative number.
Trick 2: "Two Minuses Combine Into a Plus"
The second trick is if you are subtracting a negative number, for example, 4 - -2. The
second trick is "two minuses combine into a plus". When you see the two minus signs next
to each other without a number in between them, they can combine into a plus sign. The
answer is still the same, because subtracting a negative value is the same as adding a
positive value.
Search WWH ::




Custom Search