Sprite Management

Started by
6 comments, last by Skeezix 16 years, 1 month ago
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.
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).
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.
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? :)
Create-ivity - a game development blog Mouseover for more information.
To Learn. Your picture link seems to be dead.

Thanks for your response either way :D.
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.
Create-ivity - a game development blog Mouseover for more information.
You have to copy/paste the link to the container picture, otherwise it thinks you're hotlinking.
Image and video hosting by TinyPic
so that was the picture...thanks Boder that pic really help

This topic is closed to new replies.

Advertisement