Vector math refresher
I know math isn’t the first thing people think about when talking about game development, but the truth is that it’s an important part when dealing with positions, movement, and physics. It is a great tool that will serve us well along our complete game development journey.
In this section, we’ll refresh our minds on vectors and how to manipulate them.
The 2D coordinate system
Let’s first look at how we define positions in 2D space. Two-dimensional space is defined by two axes: a horizontal axis named x and a vertical axis named y. Each point within the space can be expressed as values over these axes:
Figure 7.1 – A point in 2D space is defined by an x and a y value
Mathematically, and in this book, we write these positions as (x, y)
. The first value in the brackets is the x value and the second is the y value.
In school, you probably learned that the x-axis is positive to the right...