xVector and yVector are indeed just mere private variables
So is mass
Basically a force is what make things accelerate or decelerate.
If you don't apply any force to an object, it's speed will never change
A force is generally modeled as a vector, because as a vector, a force has a direction and a quantifiable value (how much) which is represented by the length (norm/magnitude) of the vector.
A vector in 2D has two composants often described as X and Y
In construct (classic or 2) you can't store a vector in one variable, you need one variable by composant. It is the purpose of xVector and yVector.
To calculate each composant of a vector oriented you have to find orientation and length.
gravity = G*m1*m2/d? gives you the length
the orientation is just the direction toward the considered object.
so you just have to find the unit vector (vector whose length = 1) representing this direction and multiply it by the length calculated above ('cause 1 * gravity = gravity hoho)
the unit vector is simply calculated by
cos(angle)
sin(angle)
angle = angle(source.X,source.Y,target.X,target.Y) (neat function in construct)
so just have to do a
xVector = gravity * cos(angle)
yVector = gravity * sin(angle)
I also added many times this kind of calculation because adding vector is the same as adding its composant