This project uses a binary tree search starting from 2 reference angles in order to convert an x/y coordinate into a direction and magnitude. (note: the mousex and mousey variables are displayed due to the fact that the project was developed in turbowarp, which allows you to show the 2 variables.)
Use turbowarp for best speed: https://turbowarp.org/1080874714?fps=60