Game Development Reference
In-Depth Information
file that holds all the game assets. You should just break them up into manageable
chunks. Perhaps you ' ll put assets for a given level into one resource file and assets
common to all levels in another. It
s totally up to you.
Resources might not exist in memory if they
'
ve been
thrown out to make room for other resources. You need a way to reference them
whether they are loaded or not, and these references need to uniquely identify each
resource. This resource reference enables the cache to match a particular resource
identifier with its data. For our simple resource system, an easy assumption is to sim-
ply use the filename of the original resource it is easy to read in code and guaranteed
to be unique. Some games might use something that doesn
'
veneverbeenloadedorifthey
'
'
t require parsing a file path
a typical scheme uses unique identifiers like const char *ART_TEXTURE_
GRID_DDS =
in a header file. This can work, but it is something
of a hassle because you ' ll need a place to define the constants or GUIDs, and this file
will probably change constantly and be referenced throughout your game code. The
recompiles this solution causes on even modest sized teams can bring programmers
to a crawl. The trade-off is a little processor time during resource loads as opposed to
a ton of convenience during development, which ultimately makes for a better game.
art\\grid.dds
You Might Have Multiple Resource Caches in Your Game
Different assets in your game require different resource caching. Level data, such
as object geometry and textures, should be loaded in one chunk when the level
is loaded. Audio and cinematics can be streamed in as needed. Most user
interface screens should be loaded before they are needed, since you don
t
want players to wait while you cache something in. If you are going to load
something, make sure that you load it when the player isn
'
t going to notice.
Some games just load everything they need when you begin playing and never
hit the disk for anything else at all, so a resource cache isn
'
'
t something every
game uses.
The resource cache needs a way to define the identifier of each resource in a unique
way. As discussed previously, a good solution is to just use the name of the file that
points to the resource in the Zip file:
class Resource
{
public:
std::string m_name;
Resource(const std::string &name)
{
 
Search WWH ::




Custom Search