Sign in to follow this  
vanzukeus

sprite problems

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this