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

Whenever I use BlitSurface to apply a background image, the movement of my characters is slowed drastically even though I have movement based on time:

SDL_BlitSurface( background, camera, screen, offset );

Though, if I simply fill the screen with white:

SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

The movement is exactly as I have it set.

Any idea why this could be happening?

share|improve this question
up vote 1 down vote accepted

Just a speculation: SDL_BlitSurface is lagging you down.

Test how long SDL_BlitSurface() takes; see if its significantly different from SDL_FillRect(). This will affect your character movements depending on how you implemented your game loop and physics.

share|improve this answer
I don't believe it's lagging, because my animations are running perfectly fine and are also based on time. Let me pastebin: – Corey Jun 4 '13 at 19:27
if you are talking about lines 744-747 then your game loop is trying to blit to the screen as often as it can even if it is not drawing that frame. You should only need to blit the camera view to the screen once per draw. – UnderscoreZero Jun 4 '13 at 19:52
@UnderscoreZero Oh, I see. Would you mind clarifying though? What should I do as an alternative? If I take the blitting out of the gameloop, my character will leave a trail. You said "even if it not drawing that frame." But isn't it drawing the frame every loop? Maybe I'm confused about the wording. What exactly do you mean by "a draw"? – Corey Jun 4 '13 at 20:05
Average games draw 30-60 frames per second. So you should have a timer that says when you want to draw the frame. When it is time to draw, then you go through all the drawing steps (IE bliting stuff to the screen). If it is not time to draw, you check your other timers (like an update timer) or your event buffer. – UnderscoreZero Jun 4 '13 at 20:22
Gotcha, I'll give that a go. – Corey Jun 4 '13 at 20:22

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.