# DoAngular()

Sep 11th, 2017
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //Functions to converty angular behaviour to directional, based on the angle.
2. //Call when setting bool Angular for an object, as Angular = DoAngular(ptr)
3. //This ensures that the lack of decimal precision in conversion to Allegro radians
4. //does not prevent setting certain angles; causing 'drift'.
5. bool DoAngular(npc n, int deg){
6.     if ( deg % 45 != 0 ) { n->Angle = deg; return true; }
7.     else {
8.         //u,d,l,r,lu,ru,ld,rd
9.         int dgs[8]={ 270, 90, 180, 0, 225, 315, 135, 45 };
10.         for ( int q = 0; q < 8; q++ ) {
11.             if ( deg == gds[q] ){
12.                 n->Dir = q;
13.                 return false;
14.             }
15.         }
16.     }
17. }
18.
19. bool DoAngular(lweapon n, int deg){
20.     if ( deg % 45 != 0 ) { n->Angle = deg; return true; }
21.     else {
22.         //u,d,l,r,lu,ru,ld,rd
23.         int dgs[8]={ 270, 90, 180, 0, 225, 315, 135, 45 };
24.         for ( int q = 0; q < 8; q++ ) {
25.             if ( deg == gds[q] ){
26.                 n->Dir = q;
27.                 return false;
28.             }
29.         }
30.     }
31. }
32.
33. bool DoAngular(eweapon n, int deg){
34.     if ( deg % 45 != 0 ) { n->Angle = deg; return true; }
35.     else {
36.         //u,d,l,r,lu,ru,ld,rd
37.         int dgs[8]={ 270, 90, 180, 0, 225, 315, 135, 45 };
38.         for ( int q = 0; q < 8; q++ ) {
39.             if ( deg == gds[q] ){
40.                 n->Dir = q;
41.                 return false;
42.             }
43.         }
44.     }
45. }
RAW Paste Data