Game Development Reference
In-Depth Information
Open-mapped games such as flight simulators, fantasy role-playing games, or action/
adventure games have a much tougher problem. The maps are huge and relatively
open, and the game designers have little or no control over where the player will go
next. Players also expect an incredible level of detail in these games. They want to
read the headlines in newspapers or see individual leaves on the trees, while tall
buildings across the river are in plain view. Players like that alternate reality. One of
the best games that uses this open world design is Grand Theft Auto.
Modern operating systems have more options for multithreading, especially for cach-
ing in game areas while the CPU has some extra time. They use the player ' s direction
of travel to predict the most likely areas that will be needed shortly and add those
resources to a list that is loaded on an ad hoc basis as the cache gets some time to
do extra work. This is especially beneficial if the game designers can give the cache
some hints, such as the destination of a path or the existence of pinch points, such as
a tunnel. These map elements almost serve as pinch points, similar to the hallways in
Halo, although players can always turn around and go the other direction.
Batch Your Cache Reads if You Can
Create your cache to load multiple resources at one time and sort your cache
reads in the order in which they appear in the file. This will minimize any
seeking activity on the part of the drive
s read head. If your resource file is
organized properly, the resources used together will appear next to each
other in the file. It will then be probable that resource loads will be
accomplished in a single read block with as few seeks as possible.
'
A good example of this is to use a method to preload resources into your cache:
int ResCache::Preload(const std::string pattern,
void (*progressCallback)(int, bool &))
{
if (m_file==NULL)
return 0;
int numFiles = m_file->VGetNumResources();
int loaded = 0;
bool cancel = false;
for (int i=0; i<numFiles; ++i)
{
Resource resource(m_file->VGetResourceName(i));
if (WildcardMatch(pattern.c_str(), resource.m_name.c_str()))
{
 
Search WWH ::




Custom Search