JavaScript Math Issues
So I’m building a ‘radar’ for a game. It consists of a background png and some JavaScript code that allows the user to click and drag to draw a line. Now the code is meant to display the ‘heading’ of the line. If anyone fancies aviation, you know that planes fly in headings like a compass. This radar is meant to do that, but for some reason the code that I used, when I drag the mouse perpendicularly upwards, the heading displays 180 when it should be 360/000 degrees (north), when I drag to the right the heading is 090, which is correct, when I drag downwards the heading is 360/000 when it should be 180 degrees (south), and when I drag the heading to the left the heading is correct. So it seems like the “compass” is flipped vertically. The range should be 360 degrees moving clockwise. Can anyone help? I’m pretty new to coding. The site is running on GitHub and has the necessary png, css and html files.