Almost finished, 90 degrees off
Nelson Cole

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

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

Nelson Cole

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

Try 1.5 * AL_PI or 2.5 * AL_PI?

Jonatan Hedborg

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

Nelson Cole

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

Thread #562941. Printed from Allegro.cc