I've noticed some games put all or most of their sprites into a single file, imo it would be simpler to just have one file for each image, being a total newbie to video game development, I don't see what the advantage of having a single file is, could someone explain the advantages and disadvantages of both methods?
Thanks.
What are the advantages of using a tileset?
Page 1 of 17 Replies - 662 Views - Last Post: 31 January 2012 - 09:35 AM
Topic Sponsor:
Replies To: What are the advantages of using a tileset?
#2
Re: What are the advantages of using a tileset?
Posted 15 January 2012 - 04:03 AM
Firstly, I'm not an expert on the intricate workings of XNA but I would assume that loading a 1mb file would be faster than loading 1024 1kb files. Secondly, it allows you to easily animate through sprite sheets. Thirdly it sorts images into categories. For example you could have a file that houses the player and all his/her items, then a file that houses a certain type of enemy and all its items and so on.
Of course you don't ever have to do this if you don't want.
Of course you don't ever have to do this if you don't want.
#3
Re: What are the advantages of using a tileset?
Posted 30 January 2012 - 11:11 PM
It can also make modding much easier, as can be seen in Minecraft texture packs. All you have to do is replace 1 file, not 1 file for all the 150 or so blocks.
#4
Re: What are the advantages of using a tileset?
Posted 31 January 2012 - 06:39 AM
Simply put, speed. First off, its faster to load a single large file than it is to load multiple smaller ones. Next, with modern GPUs, sprites are actually textures, and it is faster to access a sub-texture within a larger texture than it is to load a small one and display it. This is especially true if you are having to swap textures out of video memory all the time, a (relatively) expensive task.
If it helps you to visualize it, a spritesheet is essentially create a cache, just you are doing it at the graphic primitive level instead of in code.
If it helps you to visualize it, a spritesheet is essentially create a cache, just you are doing it at the graphic primitive level instead of in code.
#5
Re: What are the advantages of using a tileset?
Posted 31 January 2012 - 06:45 AM
RandomOctopus pretty much nailed the primary reason why we use large files filled with tons of "sprites". Reading one file that houses 100 sprites and saving it to memory to use later is considerably faster than constantly reading 100 different files. Hard drive read/write speeds cannot possibly compare to the speed of memory. The less often you have to rely on pulling something from the hard drive as opposed to memory, the faster your program, or game in this case, is going to be.
EDIT: Quick fingers there, Serapth.
EDIT: Quick fingers there, Serapth.
This post has been edited by Kilorn: 31 January 2012 - 06:46 AM
#6
Re: What are the advantages of using a tileset?
Posted 31 January 2012 - 08:37 AM
Imagine the loading code as well!
And also the drawing code!
Okay so that isn't so horrific, but the loading would be.
// lots of images
for(num frames of walk animation)
{
load image into array
}
for(num frames of jump animation)
{
load image into array
}
// one image loadCharacterSpriteSheet(); // Ta da!
And also the drawing code!
// lots of images
function setCurrentFrameArray(currentArray) {}
for(currentFrameArray)
{
showFrame[]
}
// one image
for(currentTileRow)
{
showFrame[]
}
Okay so that isn't so horrific, but the loading would be.
#7
Re: What are the advantages of using a tileset?
Posted 31 January 2012 - 09:27 AM
That's actually a wash staycrisp.
Your loading code would be smaller, but you would have added code for handling sprite offsets and such.
Your loading code would be smaller, but you would have added code for handling sprite offsets and such.
#8
Re: What are the advantages of using a tileset?
Posted 31 January 2012 - 09:35 AM
Handling the offsets would not take too much code. The benefits still outweigh the costs.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote








|