Take the 2-minute tour ×

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:


The movement is exactly as I have it set.

Any idea why this could be happening?

share|improve this question
add comment

1 Answer

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: pastebin.com/ynCkUXyB –  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
show 1 more comment

Your Answer


