I found good tutorial on how to do mouse look for 2D game here: http://www.atburrow.com/2010/03/08/objects-facing-the-cursor/
My code looks like this:
w = (double)mouse_x - (double)pos_x;
h = (double)mouse_y - (double)pos_y;
d = sqrt(w * w + h * h);
theta = asin(w / d) * 2 * ALLEGRO_PI;
Problem is i cant figure out how to translate it for Allegro 5. Tried this on many different ways and its working, but not correctly. First im not using OpenGL (its a simple project for 2D controlls) so what i did after this is:
al_draw_rotated_bitmap(playerLook, imWidth / 2, imHeight / 2, pos_x, pos_y, theta, 0);
Object is rotating a bit faster than it should be. So this is blocking me from further exploration. I also found good tutorial for blitz from guy that im subscribed: http://www.youtube.com/watch?v=zFAaILFJtCY
Just went out, but still there is something that confuse me when using Allegro fixed math and i cant learn it without good example.Do anyone know how to set this code right in allegro5 ? How to do 360 degree rotation using mouse in allegro5?