[SDL] Best way to rotate a sprite?

Florian Schmidt mista.tapas at gmx.net
Sun Jan 26 11:56:01 PST 2003


On Sun, 26 Jan 2003 18:34:36 -0000
"Tane Piper" <tane.piper at ukonline.co.uk> wrote:

> Hey everyone,
> 
> At the moment, I am using a rather dodgy control method in my game
> where the direction button changes the sprite on screen to face that
> direction,  but each direction has its own bitmap:
> 
> Up button loads bitmap 0,
> Right button load bitmap 1, etc.
> 
> What I want to do is change this so there is only one bitmap needed
> for the sprite and the buttons rotate the sprite, or make it go
> backwards or forwards along the angle it's facing - the same control
> system used in the original Grand Theft Auto.  I don't see anything in
> the SDL docs that directly allow you to control the rotation of a
> SDL_surface (and from this I can do the forward and backward motion
> along the vector of the sprite direction).  Is there any libraries
> that allow you to do this directly to the surface, or can anybody help
> with code for this problem?

To rotate sprites into arbitrary directions, you can always use openGL
and make everything textures on simple polygons. These can be rotated
like crazy. There is some learning curve involved with openGl, but it
can do this kind of thing.
-- 
mista.tapas at gmx.net
http://www.arted.biz/mista.tapas




More information about the SDL mailing list