Usually in gaming frames are stored top down not left to right. This has to do with high they are arranged in memory. It will be faster if stored top to bottom. Anyways here is a quick example of how to index through them.
Given a bitmap with 4 frames that is 64x256 ( width x height ) we can use the following.
Code:
RECT rPortion = { 0 };
const int nBmpWidth = 64; // Bitmap width
const int nbmpHeight = 256; // Bitmap height
const int nSprWidth = 64; // Sprite width
const int nSprHeight = 64; // Sprite height
const int nFrames = 4; // Frames of animation
int i;
// Cycle through frames
for( i = 0; i < nFrames; ++i )
{
SetRect( &rPortion, 0, (i * nSprHeight), nSprWidth, (i * nSprHeight) + nSprHeight );
// Assume xPos and yPos already defined...
BitBlt( hDC, xPos, yPos, nSprWidth, nSprHeight, hCDC, rPortion.left, rPortion.top, SRCCOPY );
}
Hopefully that makes sense. It shouldn't be too bad if you just think about it logically. Imagine the rectangle moving down vertically after each frame. The left and right portions won't change only the top. Then the bottom will always be the top + the height of the sprite. Good luck.