Message-Id: <199811260007.AAA23224@remus.clara.net> From: "Arthur" To: Subject: RE: Help! rotation in Allegro. Date: Thu, 26 Nov 1998 00:06:25 -0000 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal In-Reply-To: <73hodr$pa2$1@clam.niwa.cri.nz> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com > I need help. Can someone please explain to me the 256 degrees rotation > system used in Allegro, and how to use it. small example would > be nice :-) rotate_sprite(BITMAP *destination, BITMAP *source, int x, int y, fixed a); I can't remember if the source BITMAP has to be square or not, probably not. Note that the last parameter is of type fixed. To use integers you might need to use something similar to: rotate_sprite(screen, sprite, x, y, itofix(angle)); and to use floats: rotate_sprite(screen, sprite, x, y, ftofix(angle)); 256-degrees is easy enough - just another convention like degrees or radians. Instead of splitting the circle into 360 degrees or 2*pi radians, it splits it into 256 units. To convert from degrees to Allegro rotation units use the equation: angle = 256.0 * degree_angle / 360.0; > Also, I was looking through the example programs that came with > Allegro, and > one of the examples, I think it was ex22.c (the bouncing cubes one anyway) > had a line in it that went something along the lines of... > > ...= { 16 << -32, 16 << 32, 16 << -32, > etc.... > > I don't know if I quoted the exact code very well (sorry brought the wrong > file to work with me - so I'm guessing). I am unsure about what > this does, > I'm assuming that it's a bitwise operation of some sort but I'm not really > sure. sigh! Yup, << is a bit shift left, and >> is a bit shift right. They are generally used for fast multiplication in powers of 2. Eg, 16 << 1 is the same as 16*(1*2) = 32. 32 >> 2 is the same as 32/(2*2) = 8. James Arthur - jaa AT arfa DOT clara DOT net http://www.arfa.clara.net/james/ ICQ#15054819