Archived

This topic is now archived and is closed to further replies.

arwez

2d animation how?

Recommended Posts

ok this is for direct draw. I need to know how to animate my bitmaps. I have a function that scans my template and loads em in separate surfaces. Right now I have sprite frames on 3 different surfaces. How do I actually get them to blt one after each other?? Please don''t tell me I need velocity speed and crap, I just want to know how to load them continuously. THX!

Share this post


Link to post
Share on other sites
I think the best way is to keep the sprites on one surface (assuming that the surface isn''t too large). Then in your function that scans the source surface and loaded the individual sprites onto different surfaces just keep track of where those sprites are on the surface instead (source rectangles). Then keep a counter for the number of sprites in the animation and the current animation frame. So you could use someting like this:

RECT rSourceRectangles[MAX_ANIMATION_FRAMES];
int numFrames = number of frames in sprite animation;
int curFrame = current frame in sprite animation;

Then when you want to animate the sprite do something like this:

DrawSpriteFunction()
{
blt using rSourceRectangles[curFrame]

// increment current frame
if(++curFrame == numFrames) // if we are at the end of the animation
curFrame = 0; // reset the the first frame
}

Let me know if you have any questions.

Todd

Share this post


Link to post
Share on other sites