ABOUT al_draw_rotated_bitmap()

Thank you for your help, my progress is very fast.

But there is another problem.On the functions provided by ALLEGRO.

This is a function that can be used to rotate the picture.
However, my angle add, then my speed reduction, even if only 0.1 angle.

In the end, I became a tortoise.:(

I repeatedly checked my code.No speed reduction.

This is bug?Or function characteristic?
I just simply turn al_draw_bitmap into al_draw_rotated_bitmap.

Chris Katko

My first blind guess would be you're doing a unit conversion (from degrees to radians) BUT you forgot to add a .0 to the number so it's automatically converting it to an integer (chopping off all the precision!).

 al_draw_rotated_bitmap(my_bitmap, 0, 0, x, y, my_angle*360/2, 0); //no
 al_draw_rotated_bitmap(my_bitmap, 0, 0, x, y, my_angle*360/2.0, 0); //yes
 al_draw_rotated_bitmap(my_bitmap, 0, 0, x, y, my_angle*360.0/2.0, 0); //yes
 al_draw_rotated_bitmap(my_bitmap, 0, 0, x, y, my_angle*360.0/2, 0); //yes

where my_angle was originally in degrees, and you are converting it to radians using *360/2.

Edgar Reynaldo

Well I hope you're not converting like that. ;P

double deg = rad*180.0/M_PI;
double rad = deg*M_PI/180.0;

Chris Katko

Whoops! ;D

Edgar Reynaldo



C'mon, it's basic fundamental math skills here people. How many degrees are there in a circle? How many radians? If they are the same then they are equal. Put one on each side of an equation. Then divide both sides by one side or the other. You get 1 = 360.0 Degrees / 2.0*PI Radians which also equals it's own inverse. Now if you multiply a number by one you haven't changed it! If you want to go from degrees to radians, you divide by 360 and multiply by 2*PI. Conversely, multiply by 360 degrees and divide by 2*PI radians.

You're gonna have to show more code. We can't guess what you're doing.


@Chris Katko
That means his principle?
I need to keep the accuracy of the arc.
Using float, the precision will be lost.
It will still reduce the speed.
Float only guarantees six bits.
Anyway, my speed will still be reduced.
I can only use a stupid way.
Revise his speed at a time.
old code:

const float pi = 3.14;
const float Vx_min = 4.2;
const float Vy_min = 4.2;
float arc = pi / 2.0;

if (key[W] && !key[S] && !key[A] && !key[D]) {
        Vx = Vx*cos(arc);
        Vy = Vy*sin(arc);
        y -= Vy;
        x -= Vx;

al_draw_rotated_bitmap(wt, wtW / 2, wtH / 2, x + wtW / 2, y + wtH / 2, arc - pi / 2.0, 0);

Maybe,pi=3.1415926.Speed reduction is not recognized by eyes.
But in that way, the efficiency is down.


Sorry to drop in abruptly but the expression

arc - pi / 2.0

Should evaluate always to 0, as I don't see arc being changed anywhere in the (small) code you posted

If you're having a speed problem, on a modern system the al_draw_rotated_bitmap alone shouldn't be causing that.

Thread #617218. Printed from Allegro.cc