Original Post
Hey, I have an idea for a resource manager for a 2D game. Okay, in the game you would have images, sound, music, and entities. What if each of these resources was derived from a base class? The base class would have pure virtual functions that should be used for initializing, restoring, and deleting the resource. The manager would essentially be a wrapper for a linked list that would create a new node for each resource when it needed to be created. Because all the resources derived from a base class they could be added to the same list correct? Because object B witch is derived from object A is in essence an object A as well. So if object B has a pointer to object B then the linking mechanism should work fine. The basic idea is to have one class that manages resources. Each resource would have initialize, restore, and destroy base class methods. But the resource manager would be actually responsible for deleting the resource from the stack. It would also handle retrieving the resource upon request. The best way I figured to handle this is to use a cache for some resources so the manager will not have to traverse so much. Also, the list would have to be ordered. So I would need a IsTypeOf( ) for a resource or something similar to order the resources. Say all images, sounds and music up front and all sprites in the back. Maybe I can save offsets into the list where different resources begin and end. That would be like have many different linked list but just compiled into one. So what do you guys think? Am I barking up the wrong tree or what? I need some good advice here.