Hm, the code is really confusing. What exactly is going on here?
If you just want to find out the current animation frame to display, you could just do:
Edit: ...assuming every frame lasts for 1/50th of a second. I'm not sure if I read that correctly in the original post.
double dt; // Time since last update in seconds double animationTime; // Time since the animation started in seconds int numAnimationFrames; // Number of frames in animation double timePerAnimationFrame = 1.0/50; // 50 fps animationTime += dt; // Add passed time to animation int currentAnimationFrame = int(animationTime / timePerAnimationFrame) % numAnimationFrames; // Get currently displayed frame, and loop