Jump to content
  • Advertisement
Sign in to follow this  
Nayus Dante

SDL sprites leaving trails....

This topic is 4703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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? http://nayusdante.mybesthost.com/hosted/sprite_problem.zip 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!