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


C++ EntityManager::get_entities方法代码示例

本文整理汇总了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;
}
开发者ID:eoma,项目名称:totem-edk,代码行数:49,代码来源:main.cpp


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