I made a thing called AngleTools.js.
It is used to calculate angles and movements with x,y coordinates
angle
Calculate the angle between two objects in degrees. Both objects need to have x and y properties.
Eg.
distance
Calculate the distance between two objects in a straight line in pixels. Both objects need to have x and y properties.
Eg.
step
Calculate the x and y changes needed to move an object a certain distance along a certain angle.
Eg.