Jump to content
  • Advertisement
Sign in to follow this  
livengood

Sprite Management

This topic is 3870 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

What is a good Object Oriented method of handling multiple sprites? My original idea was a class that holds a linked list of sprite structures and has all the functions to load and create these structures. Any other ideas? Thanks for any help in advance.

Share this post


Link to post
Share on other sites
Advertisement
Unless you plan on using a static list (array), a linked list is the way to go. That's usually how it's done, unless you want to use some boost C++ libraries. They have some good template classes useful to this kind of thing.

offtopic: You're from Federal Way, Washington? I used to live there back in 198x. How are things going out there? I plan on moving back to that area very soon (hopefully this summer if things go as planned).

Share this post


Link to post
Share on other sites
Hey, thanks for the response its appreciated. I would use boost libraries but I would prefer to build it up myself. Thanks for the suggestion though.

Off Topic: Federal Way is gorgeous it's really my favorite place to live, even though I have only been here two years. From what I have seen the town is defiantly flourishing. Lots of new places and people.

Thanks again for your help.

Share this post


Link to post
Share on other sites
A linked list is, in my opinion, merely an implementation detail. To outside code, it shouldn't matter how these sprites are stored. Either way, which container type you should choose depends on how you're going to use it. This image should be helpfull when making such choices.

Quote:
Original post by livengood
Hey, thanks for the response its appreciated. I would use boost libraries but I would prefer to build it up myself. Thanks for the suggestion though.

You're using an OS that was built by others. You are, hopefully, using an IDE built by others. You're using a language designed by others. You are, or should be, using it's standard library.

So why ignore Boost? Let's put it this way: if Boost provides you with a usefull container, that saves you time writing and debugging one yourself, so you can focus on the more interesting parts of your game, why shouldn't you go for it? :)

Share this post


Link to post
Share on other sites
Hmm, the link works again... the host must've been down I guess.

Anyway, while it's a good thing to implement your own linked list for educational purposes, it's not a good idea to actually use it in production code. The standard library of the language you're working with provides several container classes already, such as std::deque, std::vector, std::list (yes, a doubly linked list). On top of that, Boost is an excellent library that provides even more. Parts of it will even be included in C++' standard library in the future. An important aspect of being a programmer is knowing how to use libraries. So why not invest some time learning that as well - and saving yourself a lot of time with it, too?


So yes, you should write your own list to learn how it works, but no, you shouldn't use it in your games, unless you want less reliable and less performant code while spending more time on it.

Also, a linked list is not always the best container for the job. When you're inserting or removing items from random places, it's a good choice, but for random access, not so much. A vector or deque would be better in that case. It's good to read up their characteristics before committing to a linked list just because that sounds like the best choice.

Share this post


Link to post
Share on other sites
You have to copy/paste the link to the container picture, otherwise it thinks you're hotlinking.
Image and video hosting by TinyPic

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!