![]() |
|
Pivot |
scriptX
Member #6,574
November 2005
![]() |
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... |
Pedro Avelar Gontijo
Member #5,372
January 2005
![]() |
scriptX
Member #6,574
November 2005
![]() |
Sorry, no it's a bitmap. |
Thomas Harte
Member #33
April 2000
![]() |
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). [My site] [Tetrominoes] |
Pedro Avelar Gontijo
Member #5,372
January 2005
![]() |
Then explain better what are you rotating ---------- |
scriptX
Member #6,574
November 2005
![]() |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
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)?
|
scriptX
Member #6,574
November 2005
![]() |
gnolam
Member #2,030
March 2002
![]() |
Gah. Thomas said: 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). -- |
miran
Member #2,407
June 2002
|
scriptX
Member #6,574
November 2005
![]() |
Quote: 2) Convert between radians (period: 2π ) and Allegro units (period: 256). wtf? [edit] |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Yes. One allegro "full circle" is 256 units.
|
scriptX
Member #6,574
November 2005
![]() |
Kitty Cat
Member #2,815
October 2002
![]() |
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). -- |
scriptX
Member #6,574
November 2005
![]() |
KittyCat: It's not "following" the mouse. In fact, it appears to face the opposite direction and I've tried:
[edit] |
|