0

I'm using c++98 and Allegro 4 and I'm attempting to use the rotate_sprite function. The documentation claims that in the angle parameter, 256 is a full circle and 64 is a right angle.

void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);

When testing, I found that the sprite did not rotate, but also found when I significantly increased the parameter I was able to get rotation with the number 4200000 appearing to provide a right angle.

rotate_sprite(world, plane, plane_x, plane_y, 4200000 * plane_r);
//plane_r is an int 0 to 3

So my question is why does 4200000 yield a right angle when the documentation claims a 64 will yield a right angle? And what is the actual value of a right angle? 4200000 worked in this instance, but what is the exact number for the future?

2
  • 1
    The documentation says that angle is fixed point 16. What are you passing? You might want to look at this. stackoverflow.com/questions/187713/…
    – Matt
    May 6, 2016 at 14:46
  • @Matt Oh, thanks. I missed that in the documentation. I saw itofix in the related functions. I'll try using that. May 6, 2016 at 14:50

1 Answer 1

0

The itofix function is used to turn the integer into a a fixed point 16.16 number, which is the type of the parameter. So a working version of the sample from above is:

rotate_sprite(world, plane, plane_x, plane_y, itofix(plane_r * 64));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.