[SDL] Question about animation; erasing where my sprite has been
Alan Wolfe
Atrix2 at cox.net
Sat Mar 1 11:18:05 PST 2008
Like infinity said, at the top of your drawscreen function you need to fill
your entire screen with black again (or whatever color your background is).
Or, like he also said, when you move an enemy do it this way:
1) Draw a black square over where the current enemy is
2) Move the enemy (ie change their coordinates)
3) Redraw the enemy in the new place.
This gets tricky if the enemies overlap, but it's faster if you can get it
working.
-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Michael Sullivan
Sent: Saturday, March 01, 2008 11:07 AM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Question about animation; erasing where my sprite has
been
On Sat, 2008-03-01 at 08:57 -0800, JDE wrote:
> Make sure you're flipping the screen everytime the character changes
> position.
>
> On Sat, Mar 1, 2008 at 7:14 AM, Michael Sullivan
> <michael at espersunited.com> wrote:
> I've drawn my sprite in it's original position. I move it to
> a new
> location and redraw the screen. The sprite is drawn in then
> new
> position, but also still shows in the old position. How to
> fix this?
> I'm using double-buffering, if that matters. The full code of
> my
> project in it's current state can be found at
> http://www.espersunited.com/~michael/needhelp/ourrpg/ if
> reference to it
> is necessary...
Everytime a sprite changes position, Draw::drawScreen is called. Here it
is:
void Draw::drawScreen()
{
//Draw allies
for (int i = 0; i < 4; i++)
{
printf("imageXPos[%d] = %i; imageYPos[%d] = %i\n", i,
imageXPos[i], i, imageYPos[i]);
SDL_BlitSurface(image[i], &src[i], screen, &dest[i]);
}
//Draw enemies
drawStats();
/*Draw the battle screen lines*/
drawLines();
SDL_Flip(screen);
}
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
More information about the SDL
mailing list