本文整理汇总了C++中Enemy::ai方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::ai方法的具体用法?C++ Enemy::ai怎么用?C++ Enemy::ai使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::ai方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/** @param a_ms timse (in milliseconds) since the last update. updates the game logic */
void Game::update(int a_ms)
{
Player * p;
Enemy * e;
for(int i = 0; i < m_playerList.getSize(); ++i)
{
p = (Player*)m_playerList.get(i);
if(p != (Player*)m_playerList.get(0))
{
e = (Enemy*)p;
if(m_powerUpTimeLeft > 0)
e->setIcon(1);
else
e->setIcon(2);
e->ai(a_ms);
}
int nextMove = p->getNextMove();
if(nextMove == PLAYER_MOVE_UP && (p->getY() <= 0 || m_map.getAt(p->getX(),p->getY()-1) == '#'))
p->setNextMove(PLAYER_MOVE_NONE);
if(nextMove == PLAYER_MOVE_DOWN && (p->getY() >= m_map.getHeight() - 1 || m_map.getAt(p->getX(),p->getY()+1) == '#'))
p->setNextMove(PLAYER_MOVE_NONE);
if(nextMove == PLAYER_MOVE_LEFT && (p->getX() <= 0 || m_map.getAt(p->getX() - 1, p->getY()) == '#'))
p->setNextMove(PLAYER_MOVE_NONE);
if(nextMove == PLAYER_MOVE_RIGHT && (p->getX() >= m_map.getWidth() - 1 || m_map.getAt(p->getX() + 1,p->getY()) == '#'))
p->setNextMove(PLAYER_MOVE_NONE);
if(p != (Player*)m_playerList.get(0))
e->move();
else
p->update(a_ms);
if(m_map.getAt(p->getX(),p->getY()) == 'O')
{
if(p == (Player*)m_playerList.get(0))
m_running = -1;
else if(p == (Player*)m_playerList.get(1))
m_running = -2;
}
}
timeTilRotation -= a_ms;
if(timeTilRotation <= 0)
{
rotateMap();
int rotationTime = rand() % 6 + 1;
timeTilRotation += rotationTime * 1000;
}
}