• Advertisement
Sign in to follow this  

Map Class vs Sprite? to handle tiles?

This topic is 3641 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 have CSprite class, currently handling individual sprites, with draw/load calls, am in the midst of creating an editor to handle dynamically creating worlds using it. My questions is --- realistically, should I create a Map class as well, to handle the huge quantity of tiles, or keep it to a Sprite class, and just create a SpriteList data structure, drawing them accordingly, per their "ID" on my tile map editor. Thanks for any suggestions. -Quinn

Share this post


Link to post
Share on other sites
Advertisement
Create a Map class that consists of Sprites, among other things you might want. Then you could use another data structure to store Map objects; that could be your "world." But, then again, you would probably want to create a World object that is comprised of Maps, but that is beyond the point.

Although it may seem fine to use an STL container and just store some Sprites, you're going to find that you would like some particular functions to handle these Sprites, and these functions would be appropriately placed in a Map class. Your Map class will basically act as a wrapper for an STL container of Sprites while providing related functions to act on the data structure of Sprites.

This also hides the actual storing and iteration of the Sprite data structure from anything outside of Map, and this is wanted; anything outside of Map doesn't need to know about how a Map works, it only needs to know that it can iterate over the Sprites by a provided iterator (from the Map class).

Hope this helps. As you can see, the same reasons can be applied to a World class that is consisted of a data structure of Maps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement