本文整理汇总了C++中CFileIO::GetFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileIO::GetFile方法的具体用法?C++ CFileIO::GetFile怎么用?C++ CFileIO::GetFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileIO
的用法示例。
在下文中一共展示了CFileIO::GetFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadDemo
bool LoadDemo(demoSystem& dem, int demo)
{
char name[256];
sprintf(name,"Data/Demo%i.dem",demo);
dem.mKeyBuffer.clear();
CFileIO fIO;
if(!fIO.GetFile(name,"rb"))
return false;
fIO.ReadBinary(&dem.iScrollOffset,1);
int bufsize,n;
fIO.ReadBinary(&bufsize,1);
if(bufsize>0)
{
for(n=0;n<bufsize;n++)
{
keyBuffer kb;
fIO.ReadBinary(&kb.tick,1);
fIO.ReadBinary(&kb.KeyStateChange,1);
fIO.ReadBinary(&kb.KeyStates,1);
dem.mKeyBuffer.push_back(kb);
}
}
return true;
}
示例2: SaveMap
//================================================================================================//
void Engine::SaveMap()
{
CFileIO fIO;
char sz[256];
sprintf(sz,"Data/Maps/Stage%i.stg",iStage);
if(!fIO.GetFile(sz,"wb"))
return;
int x,y;
//write block data
for(x=0;x<400;x++)
{
for(y=0;y<15;y++)
{
fIO.WriteBinary(&mTilesLayer1[x][y].ID,1);
fIO.WriteBinary(&mTilesLayer1[x][y].properties,1);
fIO.WriteBinary(&mTilesLayer2[x][y].ID,1);
fIO.WriteBinary(&mTilesLayer2[x][y].properties,1);
fIO.WriteBinary(&mTilesLayer3[x][y].ID,1);
fIO.WriteBinary(&mTilesLayer3[x][y].properties,1);
}
}
//write generators
int n = (int)mGenerators.size();
fIO.WriteBinary(&n,1);
if(n>0)
{
list<Generator>::iterator g;
for(g = mGenerators.begin(); g != mGenerators.end(); g++)
{
(*g).WriteToFile(fIO);
}
}
n = (int)mAnimGenerators.size();
fIO.WriteBinary(&n,1);
if(n>0)
{
list<AnimGenerator>::iterator g;
for(g = mAnimGenerators.begin(); g != mAnimGenerators.end(); g++)
{
(*g).WriteToFile(fIO);
}
}
fIO.ReleaseFile();
}
示例3: SaveDemo
void SaveDemo(demoSystem dem)
{
CFileIO fIO;
fIO.GetFile("Data/Demo1.dem","wb");
fIO.WriteBinary(&dem.iScrollOffset,1);
int bufsize = (int)dem.mKeyBuffer.size();
fIO.WriteBinary(&bufsize,1);
if(bufsize>0)
{
list<keyBuffer>::iterator i;
for(i = dem.mKeyBuffer.begin(); i != dem.mKeyBuffer.end(); i++)
{
fIO.WriteBinary(&(*i).tick,1);
fIO.WriteBinary(&(*i).KeyStateChange,1);
fIO.WriteBinary(&(*i).KeyStates,1);
}
}
}
示例4: LoadMapData
//================================================================================================//
bool Engine::LoadMapData()
{
char sz[256];
ClearMapArrays();
ClearMapEntities();
CFileIO fIO;
sprintf(sz,"Data/Maps/Stage%i.stg",iStage);
if(!fIO.GetFile(sz,"rb"))
return false;
int x,y;
//read block data
for(x=0;x<400;x++)
{
for(y=0;y<15;y++)
{
fIO.ReadBinary(&mTilesLayer1[x][y].ID,1);
fIO.ReadBinary(&mTilesLayer1[x][y].properties,1);
fIO.ReadBinary(&mTilesLayer2[x][y].ID,1);
fIO.ReadBinary(&mTilesLayer2[x][y].properties,1);
fIO.ReadBinary(&mTilesLayer3[x][y].ID,1);
fIO.ReadBinary(&mTilesLayer3[x][y].properties,1);
}
}
//read entities
int numEnt,n;
fIO.ReadBinary(&numEnt,1);
for(n=0;n<numEnt;n++)
{
Generator g;
g.LoadFromFile(fIO);
mGenerators.push_back(g);
}
fIO.ReadBinary(&numEnt,1);
for(n=0;n<numEnt;n++)
{
AnimGenerator g;
g.LoadFromFile(fIO);
mAnimGenerators.push_back(g);
}
return true;
}