Jump to content
  • Advertisement
Sign in to follow this  
livengood

Handling hundreds of sprites

This topic is 3642 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 am wondering how you would go about handling hundreds of the same sprite that need to be located in different positions. To give you an idea of whats going on suppose I have a 2d level and their are hundreds of coins positioned throughout the level. How would you position them? I was thinking maybe a script that holds all their positions but that would be a pain to write out. Another idea would be to write a function that positions them based on some parameters. What would you do? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Create a mapeditor and use it to place the coins..? Position them either with a script or store their positions in the map file?

Share this post


Link to post
Share on other sites
Ya, I would do a map editor but this is an old project. I suppose that would be the best solution however! Thanks either way! Sometimes just posting the questions makes me realize the answer ha ha.

Share this post


Link to post
Share on other sites
I use XML. In my map editor, I would output one Coin entity per coin in the level. Typically, it looks like:


<Entities>
<Entity template='coin' id='coin-1'>
<Property name='Position'>10,40</Property>
</Entity>
<Entity template='coin' id='coin-2'>
<Property name='position'>25,12</Property>
</Entity>
...


I place other entities than coins, too, hence the "template" attribute. Templates, in turn, are defined in another file, and the Entity entities inherit and overrite all the properties in the template. Thus, I would have:


<Templates>
<Template id='coin'>
<Property name='position'>0,0</Property>
<Property name='pickup'>true</Property>
<Property name='sprite'>coin-one</Property>
<Property name='score'>1</Property>
<Property name='sound'>bling</Property>
</Template>
...


This allows you to

Share this post


Link to post
Share on other sites
Not sure if this is what you were asking, but you should have one list of sprites, and another list of objects. Then the image is only loaded once, and you can place it any number of times.

So basically, each object would contain the position of itself, and a pointer to it's sprite.

Share this post


Link to post
Share on other sites
Nah, I was more asking for what hplus0603 said.. But like I said I kinda found my answer just posting the question. I am writing an editor for the levels now with C#. It isn't going so well unfortunately because I haven't used c# in a couple years. Either way Thanks for the response

In response to hplus0603 what library do you use to parse XML? or are you not parsing into c++?

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!