本文整理汇总了C++中Universe::physics_runtime_iteration方法的典型用法代码示例。如果您正苦于以下问题:C++ Universe::physics_runtime_iteration方法的具体用法?C++ Universe::physics_runtime_iteration怎么用?C++ Universe::physics_runtime_iteration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe
的用法示例。
在下文中一共展示了Universe::physics_runtime_iteration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_02
void test_02() {
// Create a universe
Universe universe;
// Add a bunch of objects
Object* A = new Object;
A->set_velocity(0, 1);
for ( int ii = 0; ii < 10; ++ii) {
A->set_position(ii, ii);
universe.add_object(A);
}
std::cout << "Initial conditions: \n";
debug_display_world(universe);
// Iterate the engine a few times
for (int ii = 0; ii < 5; ++ii) {
universe.physics_runtime_iteration();
std::cout << "\nIteration " << ii << ":\n";
debug_display_world(universe);
}
}
示例2: test_03
void test_03 () {
// Create a universe
Universe universe;
// Create two objects
Object* A = new Object;
Object* B = new Object;
// Set them apart, and on a collision course
A->set_position(2, 0);
A->set_velocity(-1, 0);
A->set_radius(1);
B->set_position(-2, 0);
B->set_velocity(1, 0.1);
B->set_radius(2);
// Add them to the universe
universe.add_object(A);
universe.add_object(B);
// Open a file
std::ofstream outputfile;
outputfile.open("test_03.csv");
// Start to iterate 10000 cycles
for (int ii = 0; ii < 10000; ++ii) {
// Output the positions of the two objects to a file
vec2d posA = A->get_position();
vec2d posB = B->get_position();
outputfile << posA[0] << "," << posA[1] << "," << posB[0] << "," << posB[1] << ";" << std::endl;
// Iterate the physics
universe.physics_runtime_iteration();
}
}