Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Almost finished, 90 degrees off

Credits go to Arthur Kalliokoski and Tero Laxström for helping out!
This thread is locked; no one can reply to it. rss feed Print
Almost finished, 90 degrees off
Nelson Cole
Member #6,043
July 2005

Thanks for all your tips in my previous post, i managed to get the arm to rotate (pivot actually) and follow the main characters should, only problem is the arm rotates 90 degress off, how can I correct that.

This is located in the main:

// Load arms sprite
BITMAP *arms = load_bitmap("arms.bmp", NULL);
    
float radians;

This is located in the main while loop:

radians = atan2(mouse_y - ((player->y-mapyoff+1)+15), mouse_x - ((player->x-mapxoff)+1)) + (AL_PI/2.0);

fixed allegro_degrees = ftofix( radians * 255.0 / (2.0 * AL_PI )) & 0xffffff;        

pivot_sprite(screen, arms, (player->x-mapxoff)+1, (player->y-mapyoff+1)+15, 0, 0, allegro_degrees);

Thanks

Tero Laxström
Member #2,589
July 2002
avatar

Rotate the image? Sorry, didn't quite get what's the problem? :)

--
tlax

Nelson Cole
Member #6,043
July 2005

the problem is that the image rotates 90 degrees off, the arm points to the right when the mouse is held above the player, as opposed to pointing right when the mouse is right. The rotation is 90 degrees off.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Try 1.5 * AL_PI or 2.5 * AL_PI?

They all watch too much MSNBC... they get ideas.

Jonatan Hedborg
Member #4,886
July 2004
avatar

...So add/substract 90 degrees as needed?

Nelson Cole
Member #6,043
July 2005

Thanks guys i got it working, i had to flip the actual picture by 270 degrees, and then set AL_PI to X 2.5. Thanks alot

Go to: