Novice question

Hi masters!.
Please someone take a moment to translate my poor english and answer
this:

I supposed I would be able to move some sprites through the screen with

something like this, but I’m surprised I couldn’t:

// C++ Code
// I use a SWSURFACE
// Initialize rects
while(!end)
{
	for(int i=0;i<NUM_SPRITES;i++)
		SDL_FillRect(screen, &rects[i], background);

	calculePositions(rects);

	for(int i=0;i<NUM_SPRITES;i++)
		SDL_BlitSurface(sprite, NULL, screen, &rects[i]);

	SDL_UpdateRects(screen, NUM_SPRITES, rects);

	// Handle Events
}

The problem resides in that the two first lines in the bucle don't

erase the last position of the sprite.
Any help?.--------------------
Pablo Brasero
<@Pablo>

Well…

I think you should update the screen after the SDL_FillRect().
To avoid flicker you should store the ‘old’ rectangle positions in a seperate
array and the call SDL_UpdateRects() after you blitted the sprites!

Hope that helps :wink:

Alex

Tue, 21 Mar 2000 you wrote:> Hi masters!.

Please someone take a moment to translate my poor english and answer
this:

I supposed I would be able to move some sprites through the screen with
something like this, but I’m surprised I couldn’t:

// C++ Code
// I use a SWSURFACE
// Initialize rects
while(!end)
{
for(int i=0;i<NUM_SPRITES;i++)
SDL_FillRect(screen, &rects[i], background);

  calculePositions(rects);

  for(int i=0;i<NUM_SPRITES;i++)
  	SDL_BlitSurface(sprite, NULL, screen, &rects[i]);

  SDL_UpdateRects(screen, NUM_SPRITES, rects);

  // Handle Events

}

The problem resides in that the two first lines in the bucle don’t
erase the last position of the sprite.
Any help?.


Pablo Brasero

Pablo wrote:

    Hi masters!.
    Please someone take a moment to translate my poor english and answer

this:

    I supposed I would be able to move some sprites through the screen with

something like this, but I’m surprised I couldn’t:

    // C++ Code
    // I use a SWSURFACE
    // Initialize rects
    while(!end)
    {
            for(int i=0;i<NUM_SPRITES;i++)
                    SDL_FillRect(screen, &rects[i], background);

            calculePositions(rects);

            for(int i=0;i<NUM_SPRITES;i++)
                    SDL_BlitSurface(sprite, NULL, screen, &rects[i]);

            SDL_UpdateRects(screen, NUM_SPRITES, rects);

            // Handle Events
    }

    The problem resides in that the two first lines in the bucle don't

erase the last position of the sprite.
Any help?.

Indeed the last positions of the sprites are erased (in the screen SW_SURFACE)

but you only update the new positions (in the video memory).–
____
_
/ ___
/ _
/ _
/ _
/
//
/
/
/
/
/

       LIOULT Florent
     Universit? de Caen
 @LIOULT_Florent
 www.multimania.com/flioult