[SDL] Quick Question about animation.
Scott Harper
lareon at comcast.net
Wed Mar 7 15:09:39 PST 2007
On Mar 7, 2007, at 3:33 PM, Lamonte(Scheols/Demonic) wrote:
> 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?
Unfortunately (as I'm sure many have discovered and I am currently
discovering), there's no "best" way to do something like this. You
could set a variable and draw one or the other image based on that
variable's value (meaning one more if() statement each frame), or you
could set some pointer variable to a drawing structure to point to a
different image each time it needs to switch... Those are the only
two reasonable ones I can come up with. The others a far more
obscure and unlikely.
Do either of those help at all?
I think a lot of "best" depends on how you're structuring your
entities, also.
-- Scott
More information about the SDL
mailing list