Sign in to follow this  
Nayus Dante

SDL sprites leaving trails....

Recommended Posts

I'm having a problem where the image does not clear when the screen updates. After the sprite moves, the last frame is still there underneath it. Could someone check my source code and tell me what I'm doing wrong? [url]http://nayusdante.mybesthost.com/hosted/sprite_problem.zip[/url] Ignore all the cpp files but main.cpp, as they are all blank. I apologize for any messy areas of the code, I haven't gotten around to cleaning up everything yet.

Share this post


Link to post
Share on other sites
Looks like you aren't clearing the last frame. You need something like this:

SDL_FillRect(screen, NULL, 0);

after the flip. That'll erase everything that's on the screen buffer and give you a blank (black) canvas.

Share this post


Link to post
Share on other sites
No, I'm just working command by command. I figure out what I want to do, look at several tutorials, then decide the best way to implement it in what I'm doing. I tried using some online tutorials as guides, but none of them really teach you what you're doing. I've learned a LOT more by setting my own goals and finding ways to accomplish them without being led by the hand.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nayus Dante
No, I'm just working command by command. I figure out what I want to do, look at several tutorials, then decide the best way to implement it in what I'm doing. I tried using some online tutorials as guides, but none of them really teach you what you're doing. I've learned a LOT more by setting my own goals and finding ways to accomplish them without being led by the hand.


I don't know about going it _all_ on your own. The way I learnt to program was by following what they say in a guide and then trying to change/mess around with it so that it does expected results. It's more fun that way. :P

Share this post


Link to post
Share on other sites
Out of curiosity, what's wrong with the cone3d tutorials? I'm using his sprite class right now which seems to be working very well. It uses a background replacement method rather than a fill, I think.

Oh wait, that's right. There was an error in the code where it was getting the width twice instead of getting the width and height and leaving trails. Other than that, I think it's a nice sprite system for small games.

I think there's a lot to said for using cone3d's tutorials. You get a nice sprite class, and yet you'll end up learning alot because it won't exactly fit your application. I decided to use SDL_image instead of the bitmap load. Made those changes. Found out the alpha channel didn't work, learned more. Saw the trails, and had to adjust that. All the while using a fairly proven and general framework that will be more reusable than if I started from scratch.

[Edited by - fireside on November 6, 2005 12:07:41 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this