本文整理汇总了C++中Being::isAlive方法的典型用法代码示例。如果您正苦于以下问题:C++ Being::isAlive方法的具体用法?C++ Being::isAlive怎么用?C++ Being::isAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Being
的用法示例。
在下文中一共展示了Being::isAlive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
Being *BeingManager::findNearestLivingBeing(int x, int y,
int maxTileDist,
Being::Type type) const
{
Being *closestBeing = 0;
int dist = 0;
const int maxDist = maxTileDist * 32;
Beings::const_iterator itr = mBeings.begin();
Beings::const_iterator itr_end = mBeings.end();
for (; itr != itr_end; ++itr)
{
Being *being = (*itr);
const Vector &pos = being->getPosition();
int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
if ((being->getType() == type || type == Being::UNKNOWN)
&& (d < dist || !closestBeing) // it is closer
&& being->isAlive()) // no dead beings
{
dist = d;
closestBeing = being;
}
}
return (maxDist >= dist) ? closestBeing : 0;
}
示例2:
Being *BeingManager::findBeingByPixel(int x, int y) const
{
Beings::const_iterator itr = mBeings.begin();
Beings::const_iterator itr_end = mBeings.end();
for (; itr != itr_end; ++itr)
{
Being *being = (*itr);
int xtol = being->getWidth() / 2;
int uptol = being->getHeight();
if ((being->isAlive()) &&
(being != player_node) &&
(being->getPixelX() - xtol <= x) &&
(being->getPixelX() + xtol >= x) &&
(being->getPixelY() - uptol <= y) &&
(being->getPixelY() >= y))
{
return being;
}
}
return NULL;
}
示例3: operator
bool operator() (ActorSprite *actor)
{
if (actor->getType() == ActorSprite::FLOOR_ITEM)
return false;
Game *game = Game::instance();
if (!game)
return false;
Being* b = static_cast<Being*>(actor);
uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0);
const Vector &pos = b->getPosition();
return ((int) pos.x / game->getCurrentTileWidth() == x &&
((int) pos.y / game->getCurrentTileHeight() == y
|| (int) pos.y / game->getCurrentTileHeight() == other_y) &&
b->isAlive() &&
(type == ActorSprite::UNKNOWN || b->getType() == type));
}
示例4: logic
void BeingManager::logic()
{
Beings::iterator i = mBeings.begin();
while (i != mBeings.end())
{
Being *being = (*i);
being->logic();
if (!being->isAlive() &&
Net::getGameHandler()->removeDeadBeings() &&
being->getCurrentFrame() >= 20)
{
delete being;
i = mBeings.erase(i);
}
else
{
++i;
}
}
}