本文整理汇总了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;
}
示例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;
}