Allegro.cc Forums » Programming Questions » Degrees to Radians

 Angeljruiz Member #14,553 September 2012 Hey rrybody,Im trying to simulate a tank right now and the problem i have is that every rotate method i find uses degrees, not radians, so how would i be able to convert it ? My current code is #SelectExpand 1void CheckKeys() 2{ 3 4 if (!kLeft && !kRight && !kUp && !kDown) 5 { 6 KeyDown = false; 7 return; 8 } 9 10 KeyDown = true; 11 12 if (kLeft) 13 { 14 if (KeyCounter >= KeyTick) 15 { 16 TankRotation -= 1; 17 Redraw = true; 18 KeyCounter = 0; 19 } 20 } 21 22 if (kRight) 23 { 24 if (KeyCounter >= KeyTick) 25 { 26 TankRotation += 1; 27 Redraw = true; 28 KeyCounter = 0; 29 } 30 } 31 32 if (kUp) 33 { 34 if (KeyCounter >= KeyTick) 35 { 36 TankX += (cos(ALLEGRO_PI/180 * TankRotation) * Speed); 37 TankY += (sin(ALLEGRO_PI/180 * TankRotation) * Speed); 38 Redraw = true; 39 KeyCounter = 0; 40 } 41 } 42 43 if (kDown) 44 { 45 if (KeyCounter >= KeyTick) 46 { 47 TankX += (cos(ALLEGRO_PI/180 * TankRotation)) * (Speed * -1); 48 TankY += (sin(ALLEGRO_PI/180 * TankRotation)) * (Speed * -1); 49 Redraw = true; 50 KeyCounter = 0; 51 } 52 } 53 54} ``` al_draw_rotated_bitmap(Tank, 32, 32, TankX, TankY, TankRotation*(ALLEGRO_PI/180), NULL); ``` EDIT: Updated code