fixed point help
chaseC

Hi, I am trying to use rotate sprite and when I just do something like rotate_sprite(buffer, image, 0, 0, itofix(angle); it works fine, but if I try to make it rotate int the direction of the mouse like thisint angle = atan2(int(mouse_y), int(mouse_x)); it gives me the error

error: conversion from `int' to non-scalar type `fix' requested

Can someone help? ???

gnolam

1) atan2() returns radians, so an integer wouldn't have been of much use anyway.
2) rotate_sprite() uses Allegro degrees, which are *128/π to the radian, meaning even if you would have used a float and ftofix it wouldn't have worked the way you wanted it to.
3) The conflict is because you've just met Allegro's Dreaded Fix ClassTM, which overloads the regular trig functions. Include <math.h> before <allegro.h> to scare it off.

[EDIT]
But if you're sure you actually do want to used fixed point (honestly, there's really no need for them on any non-ancient machine), skip the evil overload.
fixed angle = fixatan2(mouse_y, mouse_x);

chaseC

Oh yeah, I forgot the 128/&pi but it works now Thanks:)

Thread #591115. Printed from Allegro.cc