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


C++ TCODList::get方法代码示例

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


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

示例1: con

Actor *PlayerAI::chooseFromInventory(Actor *me, string filter) {
   static const int INV_WIDTH = 50;
   static const int INV_HEIGHT = 28;
   static TCODConsole con(INV_WIDTH, INV_HEIGHT);
   string title = "";

   // determine title of menu based on filter type. defaults to "inventory"
   if (filter == "")
      title = "inventory";
   else
      title = filter;

   con.setDefaultForeground(TCODColor(200, 180, 50));
   con.printFrame(0, 0, INV_WIDTH, INV_HEIGHT, true, TCOD_BKGND_DEFAULT,
         title.c_str());
   con.setDefaultForeground(TCODColor::white);
   int shortcut = 'a';
   int y = 1;

   TCODList<Actor *> inventory = me->getContainer()->getInventory();
   Actor *item;

   for (Actor **iter = inventory.begin(); iter != inventory.end(); iter++) {
      item = *iter;
      
      if (item == NULL)       continue;

      // apply necessary filters
      if (filter == "equipment") {
         if (!item->isEquipment())
            continue;
      } else if (filter == "equipped") {
         if (!me->getEquipment()->isEquipped(me, item))
            continue;
      }

      string itemName = item->getName();
      if (me->getEquipment()->isEquipped(me, item))
         itemName += " [equipped]";
      con.print(2, y, "(%c) - %s", shortcut, itemName.c_str());
      y++;
      shortcut++;
   }

   TCODConsole::blit(&con, 0, 0, INV_WIDTH, INV_HEIGHT, TCODConsole::root,
         engine.getScreenWidth() / 2 - INV_WIDTH / 2,
         engine.getScreenHeight() / 2 - INV_HEIGHT / 2);
   TCODConsole::flush();

   TCOD_key_t key;
   TCODSystem::waitForEvent(TCOD_EVENT_KEY_PRESS, &key, NULL, true);

   if (key.vk == TCODK_CHAR) {
      int itemIndex = key.c - 'a';
      if (itemIndex >= 0 && itemIndex < inventory.size())
         return inventory.get(itemIndex);
   }

   return NULL;
}
开发者ID:rthoward,项目名称:avast_cpp,代码行数:60,代码来源:ai.cpp

示例2: traverseLevelOrder

bool TCODBsp::traverseLevelOrder(ITCODBspCallback *listener, void *userData) {
	TCODList<TCODBsp *> stack;
	stack.push(this);
	while ( ! stack.isEmpty() ) {
		TCODBsp *node=stack.get(0);
		stack.remove(node);
		if ( node->getLeft() ) stack.push(node->getLeft());
		if ( node->getRight() ) stack.push(node->getRight());
		if (!listener->visitNode(node,userData)) return false;
	}
	return true;
}
开发者ID:Beliaar,项目名称:DCPUToolchain,代码行数:12,代码来源:bsp.cpp


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