   SDL Animation
  Hi. I have been fooling around with SDL for a while now and know how to init and draw a bitmap ( part of a bitmap ) to a sdl surface and even to make it move. So here is the question.I currently have a pong clone going, the ball is bouncing perfectly etc etc, but now i want to make the ball more 'realistic' ( iow i want it to animate while travelling ). All i want it to do is cycle 8 ball bmps every second to simulate rolling.How do i go about doing this?   
  I would create a list of SDL_Surface's and then create a timer class that would help you find out which surface to display.   ;  I have a tutorial on it.It's tutorial 17.   ;Quote:Original post by MegafoxHi. I have been fooling around with SDL for a while now and know how to init and draw a bitmap ( part of a bitmap ) to a sdl surface and even to make it move. So here is the question.I currently have a pong clone going, the ball is bouncing perfectly etc etc, but now i want to make the ball more 'realistic' ( iow i want it to animate while travelling ). All i want it to do is cycle 8 ball bmps every second to simulate rolling.How do i go about doing this?Basicly, what I did, was create a CApp::Sprite class (CApp is my namespace).When you wan't to add an image, you just call AddAnim(...) and an animation is added.  All you do then is call Update() every frame and set .Delay to whatever you want in millisecond.  How I did this was use a vector(std) of SDL_Surfaces.  Then I added a m_Frame variable.  Depending on 'Delay', in update I did:if (SDL_GetTicks() - OldTime > Delay)    Frame++;OldTime = SDL_GetTicks();Then, your done.  Just remember not to go out of bounds:if (Frame >= AllFrames.size())    Frame = 0;P.S.  I know, this isn't that good because everything is in order.  Later I will implement some kind of ID class or something which I will use for specific animation routines.Good luck!C++   ;  thanks guys! Ill have a look!EDIT:got it working!! the animation is working perfectly, now just to add the velocitys to make it move.[Edited by - Megafox on December 14, 2005 5:36:20 AM];Quote:Original post by Anonymous PosterThen, your done.  Just remember not to go out of bounds.You could bound check that quicker using a modulo operator:Frame%=AllFrames.size();   