Game Development Reference
In-Depth Information
12 - Cartesian Coordinates
Figure 12-5: Moving the white knight to the left subtracts from the coordinate.
The white knight ends up at position -2. That means 4 - 6 equals -2.
If we add or subtract a negative number, the white knight would move in the opposite
direction. If you add a negative number, the knight moves to the left . If you subtract a
negative number, the knight moves to the right . The expression -6 - -4 would be equal to -
2. The knight starts at -6 and moves to the right by 4 spaces. Notice that -6 - -4 has the
same answer as -6 + 4.
Figure 12-6: Even if the white knight starts at a negative coordinate, moving right still adds to the coordinate.
Figure 12-7: Putting two number lines together creates a Cartesian coordinate system.
The number line is the same as the X-axis. If we made the number line go up and down
Search WWH ::




Custom Search