本文整理汇总了C++中EntityManager::get_entities方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::get_entities方法的具体用法?C++ EntityManager::get_entities怎么用?C++ EntityManager::get_entities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::get_entities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char** /*argv*/)
{
std::cout << "--------------------------" << std::endl;
std::cout << "EXPLODING BOMBS EXAMPLE!" << std::endl;
std::cout << "--------------------------" << std::endl;
std::cout << "This example displays the interaction between multiple entities via uncoupled components." << std::endl;
std::cout << "--------------------------" << std::endl;
std::cout << "CREATING ENTITIES" << std::endl;
std::cout << "--------------------------" << std::endl;
EntityManager mgr;
auto boxA = make_box("BoxA", mgr);
auto boxB = make_box("BoxB", mgr);
auto bombA = make_bomb("BombA", mgr);
auto bombB = make_bomb("BombB", mgr);
std::cout << "--------------------------" << std::endl;
std::cout << "SETTING PROPERTIES" << std::endl;
std::cout << "--------------------------" << std::endl;
std::cout << "Position of " << bombA->get_name() << " is " << bombA->get<Vec2i>(PROPERTY_POSITION).get().x << ", " << bombA->get<Vec2i>(PROPERTY_POSITION).get().y << std::endl;
bombB->get<Vec2i>(PROPERTY_POSITION) = Vec2i(2,0);
boxA->get<Vec2i>(PROPERTY_POSITION) = Vec2i(2,1);
boxB->get<Vec2i>(PROPERTY_POSITION) = Vec2i(5,0);
boxA->get<int>(PROPERTY_HEALTH) = 150;
boxB->get<int>(PROPERTY_HEALTH) = 150;
std::cout << "Health of " << bombA->get_name() << " is " << bombA->get<int>(PROPERTY_HEALTH) << std::endl;
std::cout << "Health of " << bombB->get_name() << " is " << bombB->get<int>(PROPERTY_HEALTH) << std::endl;
std::cout << "--------------------------" << std::endl;
std::cout << "START EXPLOSION" << std::endl;
std::cout << "--------------------------" << std::endl;
bombA->get<int>(PROPERTY_HEALTH) = 0;
std::cout << "--------------------------" << std::endl;
std::cout << "UPDATE ENTITY MANAGER STATE" << std::endl;
std::cout << "--------------------------" << std::endl;
mgr.update();
std::cout << "--------------------------" << std::endl;
std::cout << "ENTITIES IN ENTITY MANAGER" << std::endl;
std::cout << "--------------------------" << std::endl;
for(auto entity : mgr.get_entities())
{
std::cout << entity->get_name() << std::endl;
}
std::cout << "--------------------------" << std::endl;
system("pause");
return 0;
}