I'm trying to make an Asteroids type game where you use the left stick to move around and the right stick to rotate and shoot in different directions.
I've got the left stick sorted out, but I can't figure out how to code the right stick for rotation. I want the object to be faced the same direction as the analog stick is pushed i.e. if I'm pushing the stick straight down, the rotation of the object would be set to 180 etc. The coordinates returned by the stick consist of two values, the X and Y axes, but rotation works in degrees which is one parameter, so I can't really use "setRotation" or "rotate"
I've created a very simple alternative that basically just uses the horizontal axis on the stick to add to the rotation:
if (rightStickX > 20)
{
player.rotate(rightStickX / 99);
}
if (rightStickX < - 20)
{
player.rotate(rightStickX / 99);
}
Can anyone set me on the right track here, or is this too complicated for a beginner? Or maybe I'm over-thinking this and it's really simple to do?
P.S. I'm using SFML 2.0 -RC