SDL Animation Question
Hello,
I was wondering whats the best way to switch between 2 image frames
every time I would press a key. For example, If I loaded 2 bitmaps
one will have its foot back and the other would have its foot forward
so if I would to keep running the frames back and forth it would look
like my sprite was walking. Any suggestions on the BEST way to do
this?
Thanks in advanced for any suggestions giving.
-Lamonte
They could be 2 surfaces, and you alternate which one to draw. Perhaps those 2 surfaces would be stored in an array. Or they can be different positions on the same surface, and you alternate which part of the surface to draw. There is no 'BEST' way, really. You just have to decide what is easiest for you to use in your program.
Here's a great tutorial on sprite sheets:
http://lazyfoo.net/SDL_tutorials/lesson06/index.php
And here's his main tutorial page:
http://lazyfoo.net/SDL_tutorials/index.php
That should get you started. But for a quick fix you could use a boolean value to decide which image to display...
It's ugly, but if you only need two images it'll do.
-Artum.
http://lazyfoo.net/SDL_tutorials/lesson06/index.php
And here's his main tutorial page:
http://lazyfoo.net/SDL_tutorials/index.php
That should get you started. But for a quick fix you could use a boolean value to decide which image to display...
bool DrawImageOne=true;while(stuff is happening){ if(DrawImageOne) { Draw(ImageOne); } else { Draw(ImageTwo); } DrawImageOne=!DrawImageOne;//this will alternate between true and false}
It's ugly, but if you only need two images it'll do.
-Artum.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement