Exemplo n.º 1
0
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;
}