How can I pivot a bitmap so that it follows the mouse, like this? I've got:
pivot_sprite(buffer, playerbuffer[PLAYER_ARM], (playerx+(playerbuffer[PLAYER_CURRENTFACING]->w/2)), (playery+(playerbuffer[PLAYER_CURRENTFACING]->h/2)), 16, 5, itofix( ???????? ));
??????? Should be...
Sorry, no it's a bitmap.
Otherwise look into atan2 and remember to convert the output of that (radians) correctly to the input of pivot_sprite (Allegro units in fixed point).
Then explain better what are you rotating
[edit]
Beaten and not understanding a thing
[edit]
Now understanding but still beaten
No idea what you want, but doesent
pivot_sprite(buffer, playerbuffer[PLAYER_ARM], (playerx+(playerbuffer[PLAYER_CURRENTFACING]->w/2)), (playery+(playerbuffer[PLAYER_CURRENTFACING]->h/2)), 16, 5, itofix(atan2((double)mouse_y, (double)mouse_x)));
require that atan2 returns an integer, when it (if we're talking math.h here) actually returns radians (double)?
Gah.
Otherwise look into atan2 and remember to convert the output of that (radians) correctly to the input of pivot_sprite (Allegro units in fixed point).
1) Use ftofix(). Casting atan2's output to int will just throw away information (hint: how many integers are there between -π and +π?).
2) Convert between radians (period: 2π ) and Allegro units (period: 256).
2) Convert between radians (period: 2π ) and Allegro units (period: 256).
wtf?
[edit]
Let me rephrase that... I did read that 2π = 360 degrees (correct?). So are you saying that 2π = 256 Allegro units?
Yes. One allegro "full circle" is 256 units.
Also, what mirian said is probably a good idea.
What's the trouble? Other than the 180 is an integer which may cause the compiler to return an integer, which would be 0 (or it may not, dunno).
KittyCat: It's not "following" the mouse. In fact, it appears to face the opposite direction and I've tried:
[edit]
http://img386.imageshack.us/img386/2571/a4hj.jpg[/img]