2

Hi i'm working on an SDL/C game , i've made a camera scrolling with a big background (6000*1024) and (1024*768) screen,

game.screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE ); 

so if i want to blit something on the screen as a destenation :

apply_surface( xxx, yyy, map.BALL, game.screen, NULL );

it will follow the camera when moving, wich it's not the case for ennemies they should move on the background and not the screen !

so if i blit something on the background as destination i have a problèmeas following,

apply_surface( xxx, yyy, map.BALL, map.background, NULL );

the old images stays on the background when moving as the folowing pictures :

Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58

1 Answers1

0

First I have to say that your way of implementing camera scrolling is quite heavy. I would recommend that you would just draw the objects directly to the screen surface taking the camera position into account.

If you want stick with your plan, you should clear your background before redrawing it. This can be done using command SDL_FillRect.

// Replace 101, 102, 103 with the background color you want
SDL_FillRect(map.background, NULL, SDL_MapRGB(map.background->format, 101, 102, 103));
Scintillo
  • 1,634
  • 1
  • 15
  • 29