[SDL] Best way to rotate a sprite?
thebigcheese at jobybednar.com
Tue Jan 28 14:42:00 PST 2003
Can't you just rotate a sprite by creating a 2D plane and mapping the bmp to it and rotating the plane using the 3D interfaces? I'm assuming by using the 3D stuff you then need to make sure that they have OpenGL, but wouldn't that work as well if you wanted to rotate realistically rather than being limited to a set number of angles?
Give someone a program - frustrate them for a day.
Teach them how to program - frustrate them for a lifetime.
---------- Original Message ----------------------------------
From: Sami Näätänen <sami.naatanen at kolumbus.fi>
Reply-To: sdl at libsdl.org
Date: Wed, 29 Jan 2003 00:30:14 +0200
>On Tuesday 28 January 2003 22:54, Sami Näätänen wrote:
>> > > PS. With 32 (or 16) steps you can use logical and to clamp the
>> > > angle after increasing or decreasing it.
>> > >
>> > > angle = (angle + 1) & $1F; // clamps the angle between 0 and 31
>> > > angle = (angle - 1) & $1F; // clamps the angle between 0 and 31
>> angle = (angle + 1) % 32;
>> angle = (angle - 1) % 32;
>In fact the above thing doesn't work correctly, because the C standard
>defines the %-operator as mathematically correct reminder operation.
>So the -1 % 32 = -1, but we want it to be 31.
>Some compilers make the two above codes identical, although they
>Should have checked that before posting, but completly forget that. Too
>much old and/or buggy compiler experience.
>SDL mailing list
>SDL at libsdl.org
More information about the SDL