本文整理汇总了C++中Universe::remove_object方法的典型用法代码示例。如果您正苦于以下问题:C++ Universe::remove_object方法的具体用法?C++ Universe::remove_object怎么用?C++ Universe::remove_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe
的用法示例。
在下文中一共展示了Universe::remove_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_00
void test_00 () {
// Show the user we are running test 00
std::cout << "Running test_00..." << std::endl << std::endl;
// Make the universe
Universe universe;
// Open a new scope when creating objects, see below why
Object* A;
Object* B;
{
// Generate a few objects
A = new Object;
B = new Object;
// Give them new positions
A->set_position(1, 1);
B->set_position(-1, 2);
// Add the objects to the universe
universe.add_object(A);
universe.add_object(B);
}
// Show a few things about the world we just created
debug_display_world(universe);
std::cout << "\nUpdating the positions\n";
// So to update the position you have to do this
A->set_position(2, 2);
A->set_velocity(3, 1);
B->set_position(-2, -2);
B->set_velocity(-1, -2);
// Display the world to the commandline
debug_display_world(universe);
// Now let's try to remove an object
std::cout << "\n Removing A" << std::endl;
debug_display_world(universe);
// Now create a new object
std::cout << "\n Adding another object C " << std::endl;
Object* C;
{
C = new Object;
C->set_position(0.5, 0.5);
universe.add_object(C);
}
// And show the mapping and world
debug_display_world(universe);
std::cout << "\n Removing B" << std::endl;
universe.remove_object(B);
debug_display_world(universe);
}