float rx = canx-(CANNON_W/2)-mouse_x;
float ry = cany-mouse_y;
angle = atan(rx/ry)/(3.1415/180);
angle = -angle;
rotate_sprite(surface, cannon, int(canx), int(cany), ftofix(angle));
float rx = canx-(CANNON_W/2)-mouse_x;
float ry = cany-mouse_y;
angle = atan(rx/ry)/(3.1415/180);
angle = -angle;
rotate_sprite(surface, cannon, int(canx), int(cany), ftofix(angle));
Quote:Given how most graphics systems are set up, I'd think you'd want:
float rx = canx-(CANNON_W/2)-mouse_x;
float ry = cany-mouse_y;
angle = atan(rx/ry)/(3.1415/180);
float rx = canx+(CANNON_W/2)-mouse_x;I'm not that familiar with Allegro though, so I could be wrong about this.Quote:I don't have an answer, but a quick Google search suggests that the Allegro function rotate_sprite() may expect the angle in a form other than radians or degrees (e.g. in the range [0,256]), so you might double-check the API reference.
Original post by moon_rabbits
I've tried all suggestions, but it is still rotating incorrectly.
I also noticed that when the mouse is all the way to the right or left, the cannon is almost completely horizontal, despite the fact that the mouse's y position is still above the cannon.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more