This simple program was meant to draw rotating sprites. However, I don't see any rotation. What's wrong?
| 1 | /*Operations on sprites*/ |
| 2 | #include <allegro.h> |
| 3 | |
| 4 | int main() |
| 5 | { |
| 6 | allegro_init(); |
| 7 | install_keyboard(); |
| 8 | set_color_depth(desktop_color_depth()); |
| 9 | set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); |
| 10 | |
| 11 | BITMAP* sprite = load_bitmap("attack_p_0.bmp",NULL); |
| 12 | |
| 13 | while(!key[KEY_ESC]) |
| 14 | { |
| 15 | for(int i=0; i<255; i++) |
| 16 | { |
| 17 | rotate_sprite(screen, sprite, 0, 0, 200); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | destroy_bitmap(sprite); |
| 22 | allegro_exit(); |
| 23 | return 0; |
| 24 | } |
| 25 | END_OF_MAIN() |
Because the 'angle' parameter of the function rotate_sprite is a fixed type. And you're passing an integer.
You should convert the integer with itofix, thus:
rotate_sprite(screen, sprite, 0, 0, itofix(200));
Thanks.:D