Recently, I have been programming a simple game. Very simple: There is a tank, and the cannon will aim at whatever position the mouse is at.
Now lets talk about the cannon graphic. The cannon graphic points to the north, with 0 rotation.
Here are the variables I have for my game, and that might be important factors for solving my problem:
Tx = The tank's X position in the world. Ty = The tank's Y position in the world. Mx = The mouse's X position in the world. My = The mouse's Y position in the world.
Also, in this programming language, the greater the Y coordinate, the lower you are. And the less the Y coordinate is, the higher you are. So, Y = 0 means the top.
My problem is, how do calculate the rotation needed for my cannon graphic to "point" to the mouse's position?
Thank you for your time.