The modulus operator returns the remainder of a division operation. If the divisor is 2 then the possible results will be 0 and 1. A common tactic is to use an array (or vector) of the divisor in size. In this case it would be two. Then the result of the modulus can be used to directly index into the array. It is very, very simple and is difficult to mess up. Here is an implementation of code that passes the array, its size, and an index and the function figures out which image to draw.
size_t DrawImageMod( Images * images[], size_t imgcount, size_t index )
{
size_t modvalue = index % imgcount;
argDrawImage( images[modvalue] );
return modvalue;
}
void DrawLoop()
{
const size_t count = 2;
Images * images[count] = { 0 };
images[0] = CreateImage(...); images[1] = CreateImage(...);
size_t index = 0;
while( ContinueDrawing() ) {
index = DrawImageMod( images, count, index );
++index;
}
DeleteImage( images[1] );
DeleteImage( images[0] );
}