Animation leaving behind a "Brighter" background?

I’m new to SDL and have been working through the tutorials on:
http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index

I have a basic app with a background and a single sprite that I can move
around w/ the arrow keys. However, for some reason it is leaving a 'streak’
behind it - as in the, the background is repainted correctly, but the
background is BRIGHTER than it was initially.

For the background, I am loading a bmp and then tiling that bmp onto another
surface (creating using SDL_CreateRGBSurface) to create the full size
background.

For an example, look here:
http://cabadam.homeip.net/streak.html

Adam Clauss
@Adam_Clauss

At 11:39 PM 22/10/2003 -0500, you wrote:

I’m new to SDL and have been working through the tutorials on:
http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index

I have a basic app with a background and a single sprite that I can move
around w/ the arrow keys. However, for some reason it is leaving a 'streak’
behind it - as in the, the background is repainted correctly, but the
background is BRIGHTER than it was initially.

For an example, look here:
http://cabadam.homeip.net/streak.html

Are you sure the background is being repainted correctly. It looks like
another case of people moving a sprite around and not repainting the
background afterwards. Even if it isnt, I think we really need to write it
in big bold letters at the top of the FAQ - this would appear to be the
most frequently asked question by people, so I think it might help if the
fact that surfaces arent cleared by default was made very clear somewhere.

If this isnt your problem though (sorry to launch off on one), then can you
explain how you’re redrawing the background each frame that might cause this?

Thanks,

Neil.

Here is just an idea to see if you really erase correctly your background.
Try to change the position of the sprite by an increment bigger than the
sprite size. If you see copies of the sprite laying on the background then
you have to debug you tiling function.

I see people have already chimed in to make sure you’re repainting your
background correctly, but more specifically, if you’re only repainting
the portion of the background that lies underneath the sprite, remember
to repaint the background using the co-ordinates from the last frame.

i.e.

Repaint background
Update sprite co-ordinates
Redraw sprite

If you’re doing something like:

Update sprite co-ordinates
Repaint background
Redraw sprite

Then you’ll have trouble. The suggestion to move the sprite by
increments larger than 1 pixel, say at least 50 pixels, is a very good
one.

— Adam Clauss wrote: > I’m new to SDL and
have been working through the tutorials on:

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index>

I have a basic app with a background and a single sprite that I can
move
around w/ the arrow keys. However, for some reason it is leaving a
’streak’
behind it - as in the, the background is repainted correctly, but the
background is BRIGHTER than it was initially.

For the background, I am loading a bmp and then tiling that bmp onto
another
surface (creating using SDL_CreateRGBSurface) to create the full size
background.

For an example, look here:
http://cabadam.homeip.net/streak.html

Adam Clauss
cabadam at houston.rr.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====

Paul Smith
Postgraduate Student
Department of Mathematics, Engineering
and Computer Science
University of Exeter


Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk

This is just a quick response - I’ll get back in more detail later.

Yes, I AM moving the sprite first, but I maintain a set of oldx,oldy
parameters that store the previous set of coordinates. I use these
coordinates to redraw just the required portion of the background.

If this were the problem though, wouldn’t I see pieces of the actual image
left behind rather than the brighter background? B/c I’ve looked closely,
and all the little specs on the background are in the same spot before and
after moving the sprite across them, but the black behind them is just
brighter.

Adam Clauss
@Adam_Clauss> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of Paul Smith
Sent: Thursday, October 23, 2003 5:32 AM
To: sdl at libsdl.org
Subject: Re: [SDL] Animation leaving behind a “Brighter” background?

I see people have already chimed in to make sure you’re
repainting your
background correctly, but more specifically, if you’re only repainting
the portion of the background that lies underneath the
sprite, remember
to repaint the background using the co-ordinates from the
last frame.

i.e.

Repaint background
Update sprite co-ordinates
Redraw sprite

If you’re doing something like:

Update sprite co-ordinates
Repaint background
Redraw sprite

Then you’ll have trouble. The suggestion to move the sprite by
increments larger than 1 pixel, say at least 50 pixels, is a very good
one.

— Adam Clauss <@Adam_Clauss> wrote: > I’m new to SDL and
have been working through the tutorials on:

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index

I have a basic app with a background and a single sprite that I can
move
around w/ the arrow keys. However, for some reason it is leaving a
’streak’
behind it - as in the, the background is repainted
correctly, but the
background is BRIGHTER than it was initially.

For the background, I am loading a bmp and then tiling that bmp onto
another
surface (creating using SDL_CreateRGBSurface) to create the
full size
background.

For an example, look here:
http://cabadam.homeip.net/streak.html

Adam Clauss
@Adam_Clauss


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====

Paul Smith
Postgraduate Student
Department of Mathematics, Engineering
and Computer Science
University of Exeter



Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— Adam Clauss wrote: > This is just a quick
response - I’ll get back in more detail later.

Yes, I AM moving the sprite first, but I maintain a set of oldx,oldy
parameters that store the previous set of coordinates. I use these
coordinates to redraw just the required portion of the background.

If this were the problem though, wouldn’t I see pieces of the actual
image
left behind rather than the brighter background? B/c I’ve looked
closely,
and all the little specs on the background are in the same spot
before and
after moving the sprite across them, but the black behind them is
just
brighter.

OK, that convinces me. If you were moving the sprite one pixel at a
time, and the outside edge of the sprite was a single colour, you
wouldn’t get bits of sprite.

Have you tried moving the sprite by larger increments? Are you using
Alpha in some way shape or form? It sounds like you could be altering
the alpha value of the background image or something. How are you
erasing the sprite? By blitting in the original background image?
Could the alpha setting of this blit have been corrupted?

Keep plugging away, you’ll get there in the end. Alternatively, cut
out as much code as possible to leave with a minimal program that still
shows the problem, then post that minimal code to the mailing list for examination.=====

Paul Smith
Postgraduate Student
Department of Mathematics, Engineering
and Computer Science
University of Exeter


Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk

Paul,
No, I’m not messing with alpha at all (at least, not intentionally). I also
just noticed that this problem on occurs in fullscreen mode - it is not
present when run in a windowed mode.

I’ve put up a small project here:
http://cabadam.homeip.net/testBackground.rar

It was written in VS.Net 2002 - but the code should port easily to whatever
you are running.
Take a look at let me know what you think. The code isn’t the cleanest, its
bits and pieces from the tutorials I’ve been reading.

Thanks,
Adam Clauss
cabadam at tamu.edu> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of Paul Smith
Sent: Thursday, October 23, 2003 11:30 AM
To: sdl at libsdl.org
Subject: RE: [SDL] Animation leaving behind a “Brighter” background?

— Adam Clauss <@Adam_Clauss> wrote: > This is
just a quick
response - I’ll get back in more detail later.

Yes, I AM moving the sprite first, but I maintain a set of oldx,oldy
parameters that store the previous set of coordinates. I use these
coordinates to redraw just the required portion of the background.

If this were the problem though, wouldn’t I see pieces of the actual
image
left behind rather than the brighter background? B/c I’ve looked
closely,
and all the little specs on the background are in the same spot
before and
after moving the sprite across them, but the black behind them is
just
brighter.

OK, that convinces me. If you were moving the sprite one pixel at a
time, and the outside edge of the sprite was a single colour, you
wouldn’t get bits of sprite.

Have you tried moving the sprite by larger increments? Are you using
Alpha in some way shape or form? It sounds like you could be altering
the alpha value of the background image or something. How are you
erasing the sprite? By blitting in the original background image?
Could the alpha setting of this blit have been corrupted?

Keep plugging away, you’ll get there in the end. Alternatively, cut
out as much code as possible to leave with a minimal program
that still
shows the problem, then post that minimal code to the mailing
list for examination.

=====

Paul Smith
Postgraduate Student
Department of Mathematics, Engineering
and Computer Science
University of Exeter



Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Did anyone get a chance to take a look at this?
Still haven’t been able to figure it out.
Thanks

Adam Clauss
cabadam at tamu.edu> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of Adam Clauss
Sent: Thursday, October 23, 2003 3:08 PM
To: sdl at libsdl.org
Subject: RE: [SDL] Animation leaving behind a “Brighter” background?

Paul,
No, I’m not messing with alpha at all (at least, not
intentionally). I also
just noticed that this problem on occurs in fullscreen mode -
it is not
present when run in a windowed mode.

I’ve put up a small project here:
http://cabadam.homeip.net/testBackground.rar

It was written in VS.Net 2002 - but the code should port
easily to whatever
you are running.
Take a look at let me know what you think. The code isn’t
the cleanest, its
bits and pieces from the tutorials I’ve been reading.

Thanks,
Adam Clauss
cabadam at tamu.edu

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of Paul Smith
Sent: Thursday, October 23, 2003 11:30 AM
To: sdl at libsdl.org
Subject: RE: [SDL] Animation leaving behind a “Brighter” background?

— Adam Clauss <@Adam_Clauss> wrote: > This is
just a quick
response - I’ll get back in more detail later.

Yes, I AM moving the sprite first, but I maintain a set
of oldx,oldy

parameters that store the previous set of coordinates. I
use these

coordinates to redraw just the required portion of the background.

If this were the problem though, wouldn’t I see pieces of
the actual

image
left behind rather than the brighter background? B/c I’ve looked
closely,
and all the little specs on the background are in the same spot
before and
after moving the sprite across them, but the black behind them is
just
brighter.

OK, that convinces me. If you were moving the sprite one pixel at a
time, and the outside edge of the sprite was a single colour, you
wouldn’t get bits of sprite.

Have you tried moving the sprite by larger increments? Are
you using
Alpha in some way shape or form? It sounds like you could
be altering
the alpha value of the background image or something. How are you
erasing the sprite? By blitting in the original background image?
Could the alpha setting of this blit have been corrupted?

Keep plugging away, you’ll get there in the end. Alternatively, cut
out as much code as possible to leave with a minimal program
that still
shows the problem, then post that minimal code to the mailing
list for examination.

=====

Paul Smith
Postgraduate Student
Department of Mathematics, Engineering
and Computer Science
University of Exeter



Want to chat instantly with your online friends? Get the
FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl