本文整理汇总了C++中Entities::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Entities::insert方法的具体用法?C++ Entities::insert怎么用?C++ Entities::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities
的用法示例。
在下文中一共展示了Entities::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layers
// ---
void QGAMES::Scene::drawOn (QGAMES::Screen* s, const QGAMES::Position& p)
{
assert (_activeMap);
if (!_entitiesPerLayer.empty ())
{
// This means, there are entities that has to be drawn in an specific layer.
// So it starts to iterate over the layers,
// drawing them, and the entities (or characters) in each
// and also keeping control which one are drawn in each layer
// to avoid they to be drawing on top of all layers.
// At this point on the code, we don't still know which entities are in each layer
std::vector <int> ePainted; // The entities that are being painted in its specific layer...
QGAMES::Layers l = _activeMap -> layers (); // Let's go to iterate per layer...
for (QGAMES::Layers::const_iterator i = l.begin (); i != l.end (); i++)
{
(*i) -> drawOn (s, p); // First of all the layer is drawn..
QGAMES::EntitiesPerLayer::const_iterator j;
// Is there something in this specific layer to be drawn?.
if ((j = _entitiesPerLayer.find ((*i) -> name ())) != _entitiesPerLayer.end ())
{
// The list of the entities and characteres to be drawn...
std::vector <int> es = (*j).second;
// ...then the entities are drawn (if they have been defined in the layer)
for (Entities::const_iterator k1 = _entities.begin ();
k1 != _entities.end (); k1++)
{
bool eFound = false;
for (std::vector <int>::const_iterator l = es.begin ();
l != es.end () && !eFound; l++)
{
if ((*k1).second ->id () == (*l))
{
eFound = true;
ePainted.push_back ((*l));
}
}
if (eFound)
(*k1).second -> drawOn (s); // The entities are drawn where they are...
}
// ...and the characters too (if they have been defined in the layer as well)
for (Entities::const_iterator k2 = _characteres.begin ();
k2 != _characteres.end (); k2++)
{
bool eFound = false;
for (std::vector <int>::const_iterator l = es.begin ();
l != es.end () && !eFound; l++)
{
if ((*k2).second ->id () == (*l))
{
eFound = true;
ePainted.push_back ((*l));
}
}
if (eFound)
(*k2).second -> drawOn (s); // The entities are drawn where they are...
}
}
}
// Entities and characteres are put into the same structure
// ...and ordered to be painted...
Entities eTP = _entities;
eTP.insert (_characteres.begin (), _characteres.end ()); // Add the characters...
eTP = orderEntitiesToDraw (eTP); // Order the set...
for (Entities::const_iterator k3 = eTP.begin ();
k3 != eTP.end (); k3++)
{
bool eFound = false;
for (std::vector <int>::const_iterator l = ePainted.begin ();
l != ePainted.end () && !eFound; l++)
if ((*k3).second ->id () == (*l))
eFound = true;
if (!eFound) // If the entity was not drawn before...
(*k3).second -> drawOn (s); // Every entity is drawn where it is...
}
}
else
{
// This means that there are no specific entities per layer...
_activeMap -> drawOn (s, p); // It is possible to alter where the map is drawn...
Entities eTP = _entities;
eTP.insert (_characteres.begin (), _characteres.end ()); // Add the characters...
eTP = orderEntitiesToDraw (eTP); // Order everything...
for (Entities::const_iterator i = eTP.begin (); i != eTP.end (); i++)
(*i).second -> drawOn (s); // ...but the entities are drawn where they are...
}
}