Hello! I'm attempting to rewrite the controller code to my soon-to-be-released Dreamcast game, and I'd like to have the analog stick determine the angle that the plane is pointing at. For example, the player points the stick to the upper right, and the ship immediately points to that angle. As the player rotates the stick, the point of the ship follows that angle. The old coin-op arcade game Time Pilot is a good example of what I'm trying to accomplish. I've done a ton of research on how to accomplish this, but can't seem to figure it out. Anyone have any ideas that I can try?

Is there a way to convert the joystick axes to angles?

Thanks in advance for any help.

EDIT: Ok... I am SOOOO close to getting this right, but having one issue. Here's my code:

`if (stickx>0)`

if (sticky<0)

angle=90+atan2(sticky,stickx);

else

angle=-90+atan2(sticky,stickx);

end

end

if (stickx<0)

if (sticky!=0)

angle=180-atan2(sticky,stickx);

end

end

(stickx and sticky refer to the axes of the analog stick)

The problem is, the second part of the code works fine. The ship points left, and at the precise angle that it's supposed to. In the first part of the code, the ship points opposite of where it's supposed to. In other words, when the ship points right and down, the ship is actually pointing up. The same happens when it points right and up... it points down instead. The rotation is backwards while the stick is pointing right. The calculations seem to be alright; I got out my scientific calculator and computed all of the equations necessary, based on what atan2 returns for each equation; hence the 90, -90, and 180-atan2. I cannot figure out, after three hours, why the right side rotation is backwards. Any math wizards here that can help?

The range of angles I get from the atan2 equations are top left: 90 degrees, middle left: 180 degrees, bottom left: -90 degrees, top right: 90 degrees, middle right: 0 degrees, bottom right: -90s degrees.