sprite flipping

Started by
5 comments, last by kburkhart84 18 years, 6 months ago
Using SDL with MSVC++ 2003. Is there a good way to flip sprites with SDL.
Advertisement
What do you mean by "flip"? Do you mean creating a mirror image of the sprite?
yes. horizontaly or verticaly
SDL only supplies very rudimentary graphics functions. For anything else you'll either have to use one of the many 2d libraries available, write yourself or even switch to OpenGL.
Check out the libsdl.org for a fairly complete list of external libraries you may use.
I read around, and supposedly the best way to do this is to have the sprite flipped in whatever direction you want beforehand, that way it doesn't have to rotate at runtime. So just open up MSPaint and select the sprite, then go to Image->Flip/Rotate. Otherwise, I'm pretty sure your stuck with writing your own rotation code, probably something to do with reading out your pixel data from the surface, rotating it, then putting it back in.
The SDL_gfx library provides functionality to rotate and manipulate SDL Surface objects.
Rob Loach [Website] [Projects] [Contact]
If you were to switch to OpenGL, you could just swap the texture coordinates.


This topic is closed to new replies.

Advertisement