I'm trying to rotate an image according to the mouse. The idea is a spaceship game. The tip of the spaceship follows the mouse cursor, depending on the cursor position the spacecraft rotates an angle.
The Allegro rotation function I am using:
al_draw_rotated_bitmap(OBJECT_TO_ROTATE,CENTER_X,CENTER_Y,X,Y,DEGREES_TO_ROTATE_IN_RADIANS);
This is the x and y position of the spaceship:
spaceship.x
spaceship.y
And the x and y position of the mouse cursor:
game_event.mouse.x
game_event.mouse.y
When the right angle to the rotation according to the mouse is identified just send the angle for the "DrawSpaceship" function. This function draws the spaceship in the main loop.
Obs: I'm using C and Allegro5