Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When animating sprites I am taking the delta difference between frames and locking the rendering frame rate of the sprite animation to the delta time.

float delay = 1000.0f / FPS;
float now = SDL_GetTicks();
if(now - sprite->last_update > delay) {
    render sprite frame

This is causing flickering because the background is being drawn faster than the sprite. (my guess) If I draw as fast as the frame rate the flickering goes away. If I slow down the background rendering then the background flickers. By slow down I mean set the FPS to 30. I want to be able to slow down the animation for a single sprite. I need a better way to lock the frame rate for individual sprites. I can slow the entire frame rate down by delaying in the game loop but I want to be able to slow down a single sprite. Is this possible?

share|improve this question
You should draw the sprite every frame. The If check you have will be to advance the frame index. – Tetrad May 30 '13 at 21:41
@Tetrad brilliant.....that makes sense and it also works...thank you – eat_a_lemon May 30 '13 at 22:12

Seeing as how you are already using SDL, I would advice taking the tutorials over at SDLtutorials.

In particular there is a tutorial on Animation which gives you an Animation CLASS, which includes framerate, frame increments, and even other more complex things like oscillation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.