Jump to content
  • Advertisement
Sign in to follow this  
vanzukeus

sprite problems

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

Hi all, I'm making a open source turn-based strategy game in c++ with SDL. In this game, there are 10-20 different units, eachone has a sprite sheet that contains 10-15 different action (move left, move right, fight right, etc) realized by a few subimages (3-5). I need an advice because I don't want to utilize a lot of memory but access a lot of time to the disk to load the image neither. Do you think that is it better to create an image for every unit that has all the subimages of all the different actions (and display in the game the opportune subimage) or, create an image for every different action of the unit and load into the memory only the images related to the most frequent actions? Another question: If I have a sprite sheet for every unit that has a different number of subimages for different actions and this differs between units too, like for example: Unit LEON: move left: *_*_*_____ move up: *_*_*_____ move down: *_*_*_*___ move right: *_*_*_____ do attack: *_*_*_*_*_ Unit FALCON: move left: *_*_*_*___ move up: *_*_*_____ move down: *_*_*_*___ move right: *_*_______ do attack: *_*_*_*_*_ where '*' is the "sub-image" and '_' is the background color (the transparent one). is it better to "create an image for every different action of the unit" right? in the other case, ("create an image for every unit that has all the subimages of all the different actions"), there will be a problem because they are not of the same lenght. In this case,what's the best thing to do ( a part make the sprites uniform) ? If the problem is not clear, tell me :) bye

Share this post


Link to post
Share on other sites
Advertisement
From the back of my envelope, 64*64 images * 20 units * 15 actions * 5 pieces = 6144000 pixels, which are an extremely affordable amount of memory and I/O; this image data can be consolidated into one or few texture atlases (less than one per unit), probably by pasting the content of separate files into large images in memory at startup.

You should eliminate all the slack around the actual sprites that your second question suggests; you know where the sprites are in the image, so rearranging them should be easy.

If you are really obsessed with memory usage, you can rebuild the spritesheet in memory at every level of the game, including only things that appear in that level; forget about privileging the "most frequent" actions, either you need the sprites or you don't.

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!