本文整理汇总了C++中word::GetObstructionMap方法的典型用法代码示例。如果您正苦于以下问题:C++ word::GetObstructionMap方法的具体用法?C++ word::GetObstructionMap怎么用?C++ word::GetObstructionMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类word
的用法示例。
在下文中一共展示了word::GetObstructionMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memset
bool
sMap::Save(const char* filename, IFileSystem& fs)
{
// do some preliminary checking...
// the start layer should not have parallax
m_Layers[m_StartLayer].EnableParallax(false);
IFile* file = fs.Open(filename, IFileSystem::write);
if (file == NULL)
return false;
// write the map header
MAP_HEADER header;
memset(&header, 0, sizeof(header));
memcpy(header.signature, ".rmp", 4);
header.version = 1;
header.num_layers = m_Layers.size();
header.num_entities = m_Entities.size();
header.startx = m_StartX;
header.starty = m_StartY;
header.startlayer = m_StartLayer;
header.startdirection = m_StartDirection;
header.num_strings = 9;
file->Write(&header, sizeof(header));
// write the strings
WriteMapString(file, ""); // OBSOLETE
WriteMapString(file, m_MusicFile.c_str());
WriteMapString(file, ""); // OBSOLETE
WriteMapString(file, m_EntryScript.c_str());
WriteMapString(file, m_ExitScript.c_str());
WriteMapString(file, m_EdgeScripts[0].c_str());
WriteMapString(file, m_EdgeScripts[1].c_str());
WriteMapString(file, m_EdgeScripts[2].c_str());
WriteMapString(file, m_EdgeScripts[3].c_str());
// write layers
for (int i = 0; i < m_Layers.size(); i++)
{
const sLayer& layer = m_Layers[i];
const sObstructionMap& obstructions = layer.GetObstructionMap();
// write the header
LAYER_HEADER lh;
memset(&lh, 0, sizeof(lh));
lh.width = m_Layers[i].GetWidth();
lh.height = m_Layers[i].GetHeight();
lh.flags = (m_Layers[i].IsVisible() ? 0 : 1) | (m_Layers[i].HasParallax() ? 2 : 0);
lh.parallax_x = m_Layers[i].GetXParallax();
lh.parallax_y = m_Layers[i].GetYParallax();
lh.scrolling_x = m_Layers[i].GetXScrolling();
lh.scrolling_y = m_Layers[i].GetYScrolling();
lh.num_segments = obstructions.GetNumSegments();
lh.reflective = (m_Layers[i].IsReflective() ? 1 : 0);
file->Write(&lh, sizeof(lh));
// write the layer name
WriteMapString(file, m_Layers[i].GetName());
// write the layer data
for (int iy = 0; iy < m_Layers[i].GetHeight(); iy++)
for (int ix = 0; ix < m_Layers[i].GetWidth(); ix++)
{
word w = m_Layers[i].GetTile(ix, iy);
file->Write(&w, 2);
}
// write the obstruction map
for (int i = 0; i < obstructions.GetNumSegments(); i++) {
const sObstructionMap::Segment& s = obstructions.GetSegment(i);
dword x1 = s.x1;
dword y1 = s.y1;
dword x2 = s.x2;
dword y2 = s.y2;
file->Write(&x1, sizeof(dword));
file->Write(&y1, sizeof(dword));
file->Write(&x2, sizeof(dword));
file->Write(&y2, sizeof(dword));
}
} // end for layer
// write entities
for (int i = 0; i < m_Entities.size(); i++)
{
// write the header
ENTITY_HEADER eh;
memset(&eh, 0, sizeof(eh));
eh.mapx = m_Entities[i]->x;
eh.mapy = m_Entities[i]->y;
eh.layer = m_Entities[i]->layer;
switch (m_Entities[i]->GetEntityType())
{
case sEntity::PERSON: eh.type = 1; break;
case sEntity::TRIGGER: eh.type = 2; break;
}
file->Write(&eh, sizeof(eh));
//.........这里部分代码省略.........