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