NOGDUS $1670.00 has been donated to NOGDUS!
July 20, 2017, 11:40:40 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Why do people put sprites in one file?  (Read 2987 times)
0 Members and 1 Guest are viewing this topic.
Richard Marks
Administrator
Offline Offline

Respect: 3425
« on: August 09, 2009, 09:48:12 AM »

I had this guy ask this question today, and I felt I should write this here in addition to answering him where he asked.

Quote
Original post by some-idiot
Why do people put lots or even all of their game sprites in one image file? I guess it was some sort of optimisation year ago, but is it wise to do it know too? Code would be much clearer if every frame of animation is a separate image file.

If you aren't talking about for 3D accelerated games as the other people assumed...

Lets say for example you were making an RTS game.
You are likely to have several thousand frames of animation.
Like perhaps each unit has 16 directions of movement, and 4 frames of animation for each of 10 actions.

That would be 640 total frames of animation for each unit.
Now, lets say that you have 10 units in 4 categories each.

If you wanted to animate your user interface icons and the environment tiles (which no really well made RTS doesn't do this) that is going to really increase the number of images that your game uses.

So lets cap the number of icons to 20 with 3 state images. Unselected, Selected, and MouseHover.

I'll say that there are 16 animated environment tiles with 3 frames of animation each.
And another 512 non animated environment tiles.

So now we have a grand total of 26,220 images!

And that is really being "simple" with the design.

So you would rather have 26,220 image files littering your project's directory, rather than four?

1 for the units
1 for the non animated environment tiles
1 for the animated environment tiles
1 for the user interface icons

Hmm.. 4 files versus 26,220 files..

Sorry, I vote for packing as many images into a single image as I can.
Logged

Gnoll
Offline Offline

Respect: 20
« Reply #1 on: October 04, 2009, 04:28:45 AM »

A random note is the overhead for each image file (It depends on the format but at least width and height integers, PNG overhead is 63 bytes), when you combine your images into single files you are saving a lot of space!

26,220 * 63 = 1.65 megabytes. Or just .24kb for 4 images. (Not including the actual image size for either, this is assuming 1 pixel Wink ) When you are working with a huge number of images this can save a considerable amount of space.

Another factor is the file system / explorer you are using, windows explorer tends to die if you attempt to browse a folder with 100,000+ images, while a few of the same size will work fine.

Gnoll
Logged
Richard Marks
Administrator
Offline Offline

Respect: 3425
« Reply #2 on: October 04, 2009, 02:43:47 PM »

You are very much correct there Josh.

There is also a limit to the number of files per directory that you are allowed depending on the OS.

Also, if you do not have enough RAM for your system to create the thumbnails .. your computer will lock up if you open the directory.

Then of course there is the HUGE difference between file formats. Look at a 1024x1024 24-bit BMP file size and compare it to a 1024x1024 24-bit PNG file size... the PNG is more than 90% Shocked smaller in my tests.
Logged

Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!