当前位置: 首页>>代码示例>>C++>>正文


C++ IPlayerInfo::getAliveTanks方法代码示例

本文整理汇总了C++中IPlayerInfo::getAliveTanks方法的典型用法代码示例。如果您正苦于以下问题:C++ IPlayerInfo::getAliveTanks方法的具体用法?C++ IPlayerInfo::getAliveTanks怎么用?C++ IPlayerInfo::getAliveTanks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPlayerInfo的用法示例。


在下文中一共展示了IPlayerInfo::getAliveTanks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateInfo

void BaseGameView::updateInfo() {
  
  int tileSize = _tileManager->getTileSize();
  int mapHeight = _model->getMap()->getHeight() * tileSize;
  int lineSpacing = 24;
  
  int currentY = _infoOffsetY;
  int currentX = _infoOffsetX + 8;

  _displayImg->draw_rectangle(_infoOffsetX, _infoOffsetY, 
          _infoOffsetX + _backgroundInfoWidth,
          mapHeight + _displayOffset.second,
          __cBlack);

  sprintf(__drawString, "Current turn: %5d", _model->getCurrentTurnCount());
  _displayImg->draw_text(currentX, currentY, __drawString,
                          __cTurquoise1, __cBlack, 1.0, __smallFont);
  currentY += lineSpacing;

  vector<IPlayerInfo*> playerInfos = _model->getPlayersInfo();
  IPlayerInfo* cur;
  for (int i = 0; i < playerInfos.size(); i++) {
    cur = playerInfos[i];
    pair<int,int> pos = cur->getHeadquarterPosition();

    sprintf(__drawString, "Team %c - Head: (%d, %d)", cur->getPlayerMapID(), 
            pos.first, pos.second);

    _displayImg->draw_text(currentX, currentY, __drawString, 
                            __cGreen, __cBlack, 1.0, __bigFont);
    currentY += lineSpacing;

    sprintf(__drawString, "Pos\t\tHP\tAmmo\tRange");
    _displayImg->draw_text(currentX, currentY, __drawString, 
                          __cPink, __cBlack, 1.0, __smallFont);
    currentY += lineSpacing;

    list<ITank*> tanks = cur->getAliveTanks();
    for (list<ITank*>::iterator it = tanks.begin(); it != tanks.end(); ++it) {
      ITank* tank = *it;

      pos = tank->getPosition();

      sprintf(__drawString, "(%2d, %2d)\t%2d\t%4d\t%5d",
            pos.first, pos.second, 
            tank->getHP(), tank->getAmmoNumber(),
            tank->getRange());

      _displayImg->draw_text(currentX, currentY, __drawString, 
                              __cWhite, __cBlack, 1.0, __smallFont);
      currentY += lineSpacing;

    }
  }
}
开发者ID:nptai95,项目名称:tankgame-tn13,代码行数:55,代码来源:BaseGameView.cpp


注:本文中的IPlayerInfo::getAliveTanks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。