Board Thread:Questions and Answers/@comment-1490123-20140719002944/@comment-5334617-20140806155551

TOK's code above works, but it seems inelegant when the inputs are axis-aligned and the results are axis-aligned to have an intermediate representation of angles, particularly when there are degrees/radians conversions involved. Eight of the  lines in TOK's code (  through  ) can be replaced by 2 assignments and 5  s, in a more common type of solution:

If you prefer diagonal movement to be shown with the facing-up/facing-down sprites, rather than the facing-left/facing-right sprites, put the  and   lines after the   and   lines.

At the same time, replace the  and   updates with: