Allegro.cc Forums » Programming Questions » ABOUT al_draw_rotated_bitmap()

 keprast Member #16,794 January 2018 Thank you for your help, my progress is very fast.But there is another problem.On the functions provided by ALLEGRO. ```al_draw_rotated_bitmap() ``` 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 Member #1,881 January 2002 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. -----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin
 Edgar Reynaldo Member #8,592 May 2007 Well I hope you're not converting like that. ;Pdouble deg = rad*180.0/M_PI;double rad = deg*M_PI/180.0; Elizabeth Warren for President 2020! | Modern Allegro 4 and 5 binaries | Allegro 5 compile guideKing Piccolo will make it so
 Chris Katko Member #1,881 January 2002 Whoops! -----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs"Political Correctness is fascism disguised as manners" --George Carlin
 Edgar Reynaldo Member #8,592 May 2007 Katko, 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. Elizabeth Warren for President 2020! | Modern Allegro 4 and 5 binaries | Allegro 5 compile guideKing Piccolo will make it so
 keprast Member #16,794 January 2018 @Chris KatkoThat 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.
 pkrcel Member #14,001 February 2012 Sorry to drop in abruptly but the expression arc - pi / 2.0Should evaluate always to 0, as I don't see arc being changed anywhere in the (small) code you postedIf you're having a speed problem, on a modern system the al_draw_rotated_bitmap alone shouldn't be causing that. It is unlikely that Google shares your distaste for capitalism. - DerezoIf one had the eternity of time, one would do things later. - Johan Halmén
 Go to: Allegro Development Installation, Setup & Configuration Allegro.cc Comments Off-Topic Ordeals The Depot Game Design & Concepts Programming Questions Recent Threads