SDL and Sprite Flipping
Well, I've done some searching online, and surprisingly, I can't find much of anything, but is there a way in SDL to simply make a sprite facing left.... become a sprite facing right?
Well since you can get access to all the pixels you can do it yourself quite easily by moving the pixels from one surface to the other. Move the first pixel at 0,0 to the for example 32,0 if the image is 32 pixels wide.
Scanmaster_K
Scanmaster_K
If you use OpenGL with SDL, its very easy to do. Things like that are one of the reasons we decided to invest in OpenGL, even though our game isn't really 3D.
Well, the game I'm working on is a fighting game, so flipping every single sprite and treating them as completely different sprites would be overly tedious. I'm sure it can't be that hard to turn a sprite around, considering it happens all the time.
But I think I'll go with adding OpenGL. I'm not very familiar with the library at all, so would you mind perhaps giving me an example code of doing so, in cooperation with SDL?
But I think I'll go with adding OpenGL. I'm not very familiar with the library at all, so would you mind perhaps giving me an example code of doing so, in cooperation with SDL?
The canonical way of doing this in pure 2D is to have two different images/surfaces for the same sprite... one facing right, one facing left. Then which image you use is just a matter of moving a rect or pointer. Now your choice is whether to make all the direction-sprites ahead of time, or just flip/rotate the ones you have and then hang on to the surfaces.
Quote:Original post by RokkumanXRX
Well, the game I'm working on is a fighting game, so flipping every single sprite and treating them as completely different sprites would be overly tedious. I'm sure it can't be that hard to turn a sprite around, considering it happens all the time.
But I think I'll go with adding OpenGL. I'm not very familiar with the library at all, so would you mind perhaps giving me an example code of doing so, in cooperation with SDL?
Read the NeHe tutorials. They have sample source code files archived there for the tutorials, including the use of SDL.
Quote:Original post by Lazy Foo
with basic SDL, no.
just flip them before hand using MSPaint or something.
No, its possible through "basic" sdl. me and a friend of mine did this a few weeks ago. i cant remember exactly but when i return to home i will post it.
Quote:Original post by byQuote:Original post by Lazy Foo
with basic SDL, no.
just flip them before hand using MSPaint or something.
No, its possible through "basic" sdl. me and a friend of mine did this a few weeks ago. i cant remember exactly but when i return to home i will post it.
It's my tutorial 29.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement