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


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

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


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

示例1: main

int main()
{
	// initialize sdl
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER |
		SDL_INIT_AUDIO) < 0) {
		std::cout << "Could not initialize SDL. SDL error: " <<
			SDL_GetError() << std::endl;
		return -1;
	}

	ComponentManager component_mgr;
	initialize_components(component_mgr);
	EntityManager em;

	// TODO: this bool pointer that gets passed around to two classes sucks
	bool running = true;

	GraphicsSystem *graphics = new GraphicsSystem(&em, window_width, window_height);
	EventSystem *events = new EventSystem(&running, &em);
	GeometryDrawer* geometryDrawer = new GeometryDrawer(graphics->getRenderer(), graphics);
	MovementSystem* movement = new MovementSystem(&em);
	PhysicsWorld* physics_world = new PhysicsWorld(em, b2Vec2(0.0f, 981.0f)); // todo use less insane gravity
	Box2DDebugDraw* box2d_debug_draw = new Box2DDebugDraw(graphics->getRenderer(), *graphics, physics_world->getWorld());
	box2d_debug_draw->SetFlags(
		b2Draw::e_shapeBit
		| b2Draw::e_jointBit
		//| b2Draw::e_aabbBit
		| b2Draw::e_pairBit
		| b2Draw::e_centerOfMassBit
		);
	box2d_debug_draw->SetFlags(0);
	physics_world->getWorld().SetDebugDraw(box2d_debug_draw);

	/* register systems */
	em.register_system<Graphics>(graphics);
	em.register_system<KeyboardInput>(events);
	em.register_system<PhysicsBodyComponent, Movement>(movement);
	em.register_system<Transform>(geometryDrawer);
	em.register_system<PhysicsBodyComponent>(physics_world);

	//createPlayer called twice to ensure destroying an entity works correctly.
	createPlayer(em, *graphics);
	em.remove_entity(0);
	createPlayer(em, *graphics);

	createWorldEdges(em);

	auto texture = std::make_shared<Texture>(*graphics->getRenderer(), "../images/crate64.jpg");
	for (unsigned int i = 0; i < 4; ++i)
	{
		for (unsigned int j = 0; j < 4; ++j)
		{
			const b2Vec2 scale(1.0f, 1.0f);
			const b2Vec2 position(350.0f + texture->getWidth() * scale.x * i,
				200.0f + texture->getHeight() * scale.y * j);
			createRB(em, texture, position, scale);
		}
	}

	SystemManager manager(120, &running);

	manager.add(graphics);
	manager.add(events);
	manager.add(geometryDrawer);
	manager.add(physics_world);
	manager.add(movement);

#ifdef WITH_LUA
	/* add a REPL if the input is redirected */
	REPLSystem *repl = new REPLSystem(&em, &component_mgr);
	if (!isatty(fileno(stdin))) {
		manager.add(repl);
	}
#endif

	manager.loop();

	SDL_Quit();

	return 0;
}
开发者ID:ivarboms,项目名称:Objectless,代码行数:81,代码来源:main.cpp


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